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

Call subquery #1690

Open
rafsun42 opened this issue Mar 15, 2024 · 1 comment
Open

Call subquery #1690

rafsun42 opened this issue Mar 15, 2024 · 1 comment
Labels
enhancement New request override-stale To keep issues/PRs untouched from stale action

Comments

@rafsun42
Copy link
Member

Should we add call subquery to AGE? It will allow Neo4j's GraphQL library to be compatible with AGE.

Data Setup

SELECT * FROM cypher('xyz', $$
CREATE (:Actor{name:'Tom Hanks'})-[:ACTED_IN]->(:Movie{title:'Forrest Gump'}) 
$$) as (a agtype);

Two uses of call subquery

SELECT * FROM ag_catalog.cypher('xyz', $$
    MATCH (this:Movie)
    CALL {
        WITH this
        MATCH (this)<-[this0:ACTED_IN]-(this1:Actor)
        WITH ag_catalog.agtype_build_map('name', this1.name) AS this1
        RETURN collect(this1) AS var2
    }
    RETURN ag_catalog.agtype_build_map('title', this.title, 'actors', var2) AS this
$$) as ("?" agtype);
SELECT * FROM ag_catalog.cypher('xyz', $$
    UNWIND $create_param0 AS create_var0
    CALL {
        WITH create_var0
        CREATE (create_this1:Movie)
        SET
            create_this1.title = create_var0.title
        WITH create_this1, create_var0
        CALL {
            WITH create_this1, create_var0
            UNWIND create_var0.actors.create AS create_var2
            WITH create_var2.node AS create_var3, create_var2.edge AS create_var4, create_this1
            CREATE (create_this5:Actor)
            SET
                create_this5.name = create_var3.name
            MERGE (create_this1)<-[create_this6:ACTED_IN]-(create_this5)
            
            RETURN collect(NULL) AS create_var7
        }
        
        RETURN create_this1
    }
    CALL {
        WITH create_this1
        MATCH (create_this1)<-[create_this8:ACTED_IN]-(create_this9:Actor)
        WITH ag_catalog.agtype_build_map('name', create_this9.name) AS create_this9 
        RETURN collect(create_this9) AS create_var10
    }
    RETURN collect(ag_catalog.agtype_build_map('title', create_this1.title, 'actors', create_var10)) AS data
$$,
'[ { title: 'Forrest Gump', actors: { create: [{ node: { name: "Tom Hanks" } }] } } ]' -- parameter
) as ("?" agtype);

Expected output
For both queries:

[
    {
      "title": "Forrest Gump",
      "actors": [
        {
          "name": "Tom Hanks"
        }
      ]
    }
]
@rafsun42 rafsun42 added the enhancement New request label Mar 15, 2024
Copy link

This issue is stale because it has been open 45 days with no activity. Remove "Abondoned" label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale Stale issues/PRs label May 11, 2024
@MuhammadTahaNaveed MuhammadTahaNaveed added override-stale To keep issues/PRs untouched from stale action and removed Stale Stale issues/PRs labels May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New request override-stale To keep issues/PRs untouched from stale action
Projects
None yet
Development

No branches or pull requests

2 participants