You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by GitBox <gi...@apache.org> on 2021/12/04 10:25:30 UTC

[GitHub] [incubator-age] afidegnum opened a new issue #152: How can i return the graph traversa as JSON using json_build_object?

afidegnum opened a new issue #152:
URL: https://github.com/apache/incubator-age/issues/152


   I needed the following query to be represented as json. 
   
   ```
   SELECT * from cypher('text_test', $$
             MATCH (V)-[R:connect]-(V2)
             RETURN V,R,V2
   $$) as (V agtype, R agtype, V2 agtype);
   ```
   reading from agensgraph documentaiton, I noticed there is a funciton called `json_build_object` but when called, I ended up having an error of `Function ag_catalog.age_json_build_object(agtype) does not exist`
   Can you please give an example?


-- 
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-unsubscribe@age.apache.org

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



[GitHub] [incubator-age] afidegnum commented on issue #152: How can i return the graph traversa as JSON using json_build_object?

Posted by GitBox <gi...@apache.org>.
afidegnum commented on issue #152:
URL: https://github.com/apache/incubator-age/issues/152#issuecomment-986628037


   `(map agtype)`, `(list agtype)` are `map` and `list` reserved characters for `agtype`? 


-- 
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-unsubscribe@age.apache.org

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



[GitHub] [incubator-age] pdpotter commented on issue #152: How can i return the graph traversa as JSON using json_build_object?

Posted by GitBox <gi...@apache.org>.
pdpotter commented on issue #152:
URL: https://github.com/apache/incubator-age/issues/152#issuecomment-986553148


   Agesgraph (https://github.com/bitnine-oss/agensgraph) and Apache AGE (this repository) are two different projects.
   
   `json_build_object` should indeed be supported by Agensgraph, but I can't find anything on this function for Apache AGE.
   
   You could however return the results as a list
   ```
   SELECT * from cypher('text_test', $$
             MATCH (V)-[R:connect]-(V2)
             RETURN [V,R,V2]
   $$) as (list agtype);
   ```
   or as a map
   ```
   SELECT * from cypher('text_test', $$
             MATCH (V)-[R:connect]-(V2)
             RETURN {parent: V, relation: R,child: V2}
   $$) as (map agtype);
   ```


-- 
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-unsubscribe@age.apache.org

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



[GitHub] [incubator-age] joefagan commented on issue #152: How can i return the graph traversa as JSON using json_build_object?

Posted by GitBox <gi...@apache.org>.
joefagan commented on issue #152:
URL: https://github.com/apache/incubator-age/issues/152#issuecomment-986824887


   @afidegnum 
   No map and list are not reserved in SELECT ... as (map agtype)
   It returns a map or list only because the RETURN clause is shaped like 
   RETURN { , , } --returns map
   or
   RETURN [ , , ] --returns list
   
   Map and List can be replaced with foo or bar etc. It will rename the column output to foo or bar as shown in this complete example here.
   
   
   ```
   -- drop graph for cleanup between tests
   SELECT * FROM ag_catalog.drop_graph('test_graph', true);
   
   -- start from a new graph
   -- create parent connected to 2 children with multiple properties
   SELECT * FROM create_graph('test_graph');
   SELECT * FROM cypher('test_graph', $$
       CREATE (p:person {name: 'parent'})
       CREATE (c1:person {name: 'child1', age: 11 })
       CREATE (c2:person {name: 'child2', age: 12 })
       CREATE (p)-[:connect {type: 'is parent'}]->(c1)
       CREATE (p)-[:connect {type: 'is parent'}]->(c2)
       RETURN p
   $$) as (p agtype);
   
   SELECT * from cypher('test_graph', $$
             MATCH (p)-[R:connect]->(c)
             RETURN [p.name,R.type,c.name]
   $$) as (foo agtype);
   ```
   Last query returns
                   foo
   -----------------------------------
    ["parent", "is parent", "child2"]
    ["parent", "is parent", "child1"]
   


-- 
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-unsubscribe@age.apache.org

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