You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bug is related to the way the hook is implemented and how the Neo4j driver works:
defrun(self, query) ->Result:
""" Function to create a neo4j session and execute the query in the session. :param query: Neo4j query :return: Result """driver=self.get_conn()
ifnotself.connection.schema:
withdriver.session() assession:
result=session.run(query)
else:
withdriver.session(database=self.connection.schema) assession:
result=session.run(query)
returnresult
In my opinion, the above hook run method should be changed to:
defrun(self, query) ->Result:
""" Function to create a neo4j session and execute the query in the session. :param query: Neo4j query :return: Result """driver=self.get_conn()
ifnotself.connection.schema:
withdriver.session() assession:
result=session.run(query)
returnresult.data()
else:
withdriver.session(database=self.connection.schema) assession:
result=session.run(query)
returnresult.data()
This is because when trying to get result.data (or result in general) externally the session is always empty.
I tried this solution and it seems to work.
Apache Airflow Provider(s)
neo4j
Versions of Apache Airflow Providers
apache-airflow-providers-neo4j version 2.0.0
Apache Airflow version
2.1.0
Operating System
macOS Big Sur Version 11.4
Deployment
Docker-Compose
Deployment details
docker-compose version 1.29.2, build 5becea4c
Docker version 20.10.7, build f0df350
What happened
If i run the code snippet above i always get an empty response.
What you expected to happen
i would like to have the query response.
How to reproduce
I created this custom operator to test the bug.
Anything else
The bug is related to the way the hook is implemented and how the Neo4j driver works:
In my opinion, the above hook run method should be changed to:
This is because when trying to get result.data (or result in general) externally the session is always empty.
I tried this solution and it seems to work.
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: