rafsun42 opened a new issue, #1690:
URL: https://github.com/apache/age/issues/1690

   Should we add [call 
subquery](https://neo4j.com/docs/cypher-manual/current/subqueries/call-subquery/?utm_source=Google&utm_medium=PaidSearch&utm_campaign=Evergreenutm_content=AMS-Search-SEMCE-DSA-None-SEM-SEM-NonABM&utm_term=&utm_adgroup=DSA-use-cases&gad_source=1&gclid=CjwKCAjw48-vBhBbEiwAzqrZVLKhZ3Swr9FxOtwkjpaA9BWPj8vjzbjxoapsZf0gapp3RPktxKf2BxoCnWwQAvD_BwE)
 to AGE? It will allow Neo4j's GraphQL library to be compatible with AGE.
   
   **Data Setup**
   ```sql
   SELECT * FROM cypher('xyz', $$
   CREATE (:Actor{name:'Tom Hanks'})-[:ACTED_IN]->(:Movie{title:'Forrest 
Gump'}) 
   $$) as (a agtype);
   ```
   
   **Two uses of call subquery**
   
   1)
   ```sql
   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);
   ```
   
   2) 
   ```sql
   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"
           }
         ]
       }
   ]
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@age.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to