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 2022/03/20 09:48:39 UTC

[GitHub] [incubator-age] akloster opened a new issue #202: Parsing results?

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


   I'm experimenting with SQL/cypher queries from Python and I've got a problem understanding the return types. First of all, the agensgraph-python extension to psycopg2 doesn't seem to work anymore, unfortunately. So I tried to get around the parsing problem by making more explicit SQL queries like this:
   
   ```
   cursor.execute("SELECT name from cypher('master_data', $$ MATCH (a) RETURN a.name $$) as (name agtype);")
   data = cursor.fetchall()
   ```
   But the return is like  `[('"hello"')]`, so the `name` inside the sql statement is already quoted, right? Is there something I'm not understanding?


-- 
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] emotionbug edited a comment on issue #202: Parsing results?

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


   there is a casting for the basic type. so, it can be used as follows.
   
   ```
   postgres=# SELECT create_graph('test');
   SELECT * FROM cypher('test', $$
   MATCH (n) RETURN n.name
   $$) as (i text);
   postgres=# SELECT * FROM cypher('test', $$
   CREATE (a {name: 'Alex'} )
   $$) as (i agtype);
    i
   ---
   (0 rows)
   postgres=# SELECT * FROM cypher('test', $$
   MATCH (n) RETURN n.name
   $$) as (i text);
     i
   ------
    Alex
   (1 row)
   postgres=# SELECT cypher.i, pg_typeof(cypher.i) FROM (SELECT * FROM cypher('test', $$
   postgres$# MATCH (n) RETURN n.name
   postgres$# $$) as (i text)) cypher;
     i   | pg_typeof
   ------+-----------
    Alex | text
   (1 row)
   postgres=# SELECT i::text, pg_typeof(i::text) FROM cypher('test', $$
   postgres$# MATCH (n) RETURN n.name
   postgres$# $$) as (i agtype);
     i   | pg_typeof
   ------+-----------
    Alex | text
   (1 row)
   ```


-- 
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] emotionbug commented on issue #202: Parsing results?

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


   there is a casting for the basic type. so, it can be used as follows.
   
   ```
   postgres=# SELECT create_graph('test');
   SELECT * FROM cypher('test', $$
   MATCH (n) RETURN n.name
   $$) as (i text);
   postgres=# SELECT * FROM cypher('test', $$
   CREATE (a {name: 'Alex'} )
   $$) as (i agtype);
    i
   ---
   (0 rows)
   postgres=# SELECT * FROM cypher('test', $$
   MATCH (n) RETURN n.name
   $$) as (i text);
     i
   ------
    Alex
   (1 row)
   postgres=# SELECT cypher.i, pg_typeof(cypher.i) FROM (SELECT * FROM cypher('test', $$
   postgres$# MATCH (n) RETURN n.name
   postgres$# $$) as (i text)) cypher;
     i   | pg_typeof
   ------+-----------
    Alex | text
   (1 row)
   postgres=# SELECT i::text, pg_typeof(i::text) FROM cypher('test', $$
   postgres$# MATCH (n) RETURN n.name
   postgres$# $$) as (i text);
     i   | pg_typeof
   ------+-----------
    Alex | text
   (1 row)
   ```


-- 
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] emotionbug commented on issue #202: Parsing results?

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


   When you need parser for agtype on python, reference here.
   https://github.com/apache/incubator-age/tree/master/drivers/python
   
   But, case like your query can be alternate from agtype to text.


-- 
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] akloster commented on issue #202: Parsing results?

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


   Thank you, this is very helpful!


-- 
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 #202: Parsing results?

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


   The agtype type is based on jsonb. Returned results are JSON-like.
   
   The ANTLR parser file (https://github.com/apache/incubator-age/blob/master/drivers/Agtype.g4#L64) indicates  that string values should indeed be double quoted.


-- 
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] akloster closed issue #202: Parsing results?

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


   


-- 
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] akloster commented on issue #202: Parsing results?

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


   Thank you, that wasn't immediately obvious to me. Also I recommend renaming the driver module from `age` to something like `apache_age` or `psycopg2_age`. 
   
   If using cypher as a subquery to return a string property inside SQL, how would you recommend to "unquote" the string?


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