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/03/19 18:55:52 UTC

[GitHub] [incubator-age] jhgoodwin opened a new issue #47: Examples of how to join relational data

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


   Hi, I was able to use some examples to create records such as:
   
   ```sql
   SELECT q.a
   FROM (SELECT *
         FROM cypher('test_graph', $$
     MATCH (a:Part)
     RETURN a
   $$) AS (a agtype)
        ) as q;
   ```
   Which returns:
   ```
   a
   "{""id"": 844424930131974, ""label"": ""Part"", ""properties"": {""part_num"": ""123""}}::vertex"
   "{""id"": 844424930131975, ""label"": ""Part"", ""properties"": {""part_num"": ""345""}}::vertex"
   "{""id"": 844424930131976, ""label"": ""Part"", ""properties"": {""part_num"": ""456""}}::vertex"
   "{""id"": 844424930131977, ""label"": ""Part"", ""properties"": {""part_num"": ""789""}}::vertex"
   ```
   
   But, it's unclear to me how I would join these results against typical relational concepts. Would someone be willing to share an example or point me at documentation for this?


-- 
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.

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



[GitHub] [incubator-age] jhgoodwin commented on issue #47: Examples of how to join relational data

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


   Thanks for the guide @JoshInnis . That got me pretty close to what I was looking for.  Looks like many type conversions are not yet supported - a pity.
   
   I was able to figure this out, which does work:
   
   ```sql
   WITH graph_query as (
       SELECT *
       FROM cypher( 'test_graph', $$MATCH (n) RETURN n.part_num$$
           ) as (part_num text)
       )
   SELECT (g.part_num::json)#>> '{}' as part_num
   FROM graph_query g
   WHERE g.part_num = '"123"'
   ;
   ```
   This will deconstruct the string value of 123 from the row. Feels like there probably is a simpler way. Maybe you know it.
   From here, joining against a relational table should be trivial.  Looks like part of what I was missing before is the as clause with the parenthesis syntax is how you define the row datatype of the cypher function.


-- 
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.

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



[GitHub] [incubator-age] JoshInnis closed issue #47: Examples of how to join relational data

Posted by GitBox <gi...@apache.org>.
JoshInnis closed issue #47:
URL: https://github.com/apache/incubator-age/issues/47


   


-- 
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.

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



[GitHub] [incubator-age] ehsanonline removed a comment on issue #47: Examples of how to join relational data

Posted by GitBox <gi...@apache.org>.
ehsanonline removed a comment on issue #47:
URL: https://github.com/apache/incubator-age/issues/47#issuecomment-803051341


   Hi, as far as i know, records in graph databases are `vertex` or `edge`. each edge can connect two vertex together.
   for example : `person-likes->fruit` . `person` and `fruit` are vertexes and `likes` is an edge which connect these two together.
   both edge and vertex can have properties like this: `person( name: "john" )` or `fruit(type: "apple")`.
   now your data (Part) is a vertex. you need to know [cypher queries](http://www.opencypher.org/) to deal with your data.


-- 
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.

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



[GitHub] [incubator-age] ehsanonline edited a comment on issue #47: Examples of how to join relational data

Posted by GitBox <gi...@apache.org>.
ehsanonline edited a comment on issue #47:
URL: https://github.com/apache/incubator-age/issues/47#issuecomment-803051341


   Hi, as far as i know, records in graph databases are `vertex` or `edge`. each edge can connect two vertex together.
   for example : `person-likes->fruit` . `person` and `fruit` are vertexes and `likes` is an edge which connect these two together.
   both edge and vertex can have properties like this: `person( name: "john" )` or `fruit(type: "apple")`.
   now your data (Part) is a vertex. you need to know [cypher queries](http://www.opencypher.org/) to deal with your data.


-- 
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.

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



[GitHub] [incubator-age] ehsanonline commented on issue #47: Examples of how to join relational data

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


   Hi, as far as i know, records in graph databases are `vertex` or `edge`. each edge can connect two vertex together.
   for example : `person-likes->fruit` . `person` and `fruit` are vertexes and `likes` is an edge which connect these two together.
   both edge and vertex can have properties like this: `person( name: "john" )` or `fruit(type: "apple")`.
   now your data (Part) is an vertex. you need to know [cypher queries](http://www.opencypher.org/) to deal with your data.


-- 
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.

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



[GitHub] [incubator-age] JoshInnis commented on issue #47: Examples of how to join relational data

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


   https://age.apache.org/docs/Apache_AGE_Guide.pdf
   
   In the above link, there is a section called "Advanced Queries" where there is a simple example about how to join Postgres tables.


-- 
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.

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