Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass parameters to the connector #624

Open
lvijnck opened this issue Jun 3, 2024 · 0 comments
Open

Pass parameters to the connector #624

lvijnck opened this issue Jun 3, 2024 · 0 comments

Comments

@lvijnck
Copy link

lvijnck commented Jun 3, 2024

Guidelines

Please note that GitHub issues are only meant for bug reports/feature requests. If you have questions on how to use the Neo4j Connector for Apache Spark,
please ask on the Neo4j Discussion Forum instead of creating an issue here.

Feature description (Mandatory)

Add option to pass params to Neo.

I'm working on a Kedro integration for Neo4J, and this connector seems to be perfect. However, I want to define my queries in a Pythonic way, using Pypher. This works fairly well, e.g.,


from kedro_datasets.spark import SparkDataset
from kedro_datasets.spark.spark_dataset import _get_spark

class Neo4JDataset(SparkDataset):

    ...

    def _load(self) -> Any:
      """Load Neo4J table as SparkDataset"""
      spark_session = _get_spark()
      return (
            spark_session.read.format("org.neo4j.spark.DataSource")
            .option("database", self._database)
            .option("url", self._url)
            .options(**self._credentials)
            .option("query", str(self._load_query(self._query))) 
        )

    # with self._query an arbitrary Pypher object, e.g.,
    # query = (
    #.    pypher.MATCH.node("person", labels="Person")
    #     .rel_out(labels="LIKES")
    #     .node("movie", "Movie")
    #     .RETURN(__.person.__id__.ALIAS("p"))
    # )

However, binding variables that come from the Kedro context are not possible, due to the inability to specify params. Pypher already has the bound_params attributes that yields a nicely formatted dictionary.

The inability to specify params is rather akward here, especially since predicate pushdown is disabled for the query option.

Considered alternatives

N/A

How this feature can improve the project?

Better adoption

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant