[GitHub] [age] cho2hhun commented on issue #1225: [Data Casting] 'agtype' Casting

2023-09-18 Thread via GitHub


cho2hhun commented on issue #1225:
URL: https://github.com/apache/age/issues/1225#issuecomment-1724628778

   Hi @Allison-E I've tried various Code but Problems are like that
   
   1. agtype only possible to cast as 'varchar' for string Data, not 'text' etc
   2. actually agtype is normally used to treat 'key-value' data like 'json', 
'jsonb' type, but cannot parsing as 'key-value' data in python, Java 
enviroments. only parsed as string like `"{a : 1, b : 2}"`  not like `{a : 
1, b : 2}`
   indeed in PG enviroment, it doesn't matter to use agtype because it can be 
extracted 'key' and 'value' like 'jsonb'. So I think someone have to control it 
to **possible parse in other enviroment** and to **cast into Other data type 
like '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-unsubscr...@age.apache.org

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



[GitHub] [age] cho2hhun commented on issue #1225: [Data Casting] 'agtype' Casting

2023-09-18 Thread via GitHub


cho2hhun commented on issue #1225:
URL: https://github.com/apache/age/issues/1225#issuecomment-1724693861

   @KamleshKumar427 Thank you for your advice!
   
   I'de read many times the document that you linked, But in that Document, I 
Think There are problems also :(
   
   First
   The Cypher 'List' only printed 'agtype' and with that result, there are 
nothing to do in select query, in a nutshell the 'List' that extracted from 
Cypher doesn't need and play a role as a **list or array**
   For example, to use list that extracted from Cypher,  fi**rst we may cast it 
into 'varchar'**, **second we need to cast it into 'array'**
   **With the example query of that document, the query describe extracting 
list**
   ```
   SELECT *
   FROM cypher('graph_name', $$
   WITH [null] as lst
   RETURN lst
   $$) AS (lst agtype);
   ```
   if u run this query, then list column 'lst' will be extracted. but to 
utilize in SQL query, it is nothing... it is not array or list even not any 
string So to use this, maybe need to two-times casting like below
   `SELECT string_to_array(lst::varchar, ',')
   FROM cypher('graph_name', $$
   WITH [null] as lst
   RETURN lst
   $$) AS (lst agtype);'
   actually to use list that extracted cypher need two-times casting for using 
in SQL, SO I dont think it is efficient.
   **Hence, automatical 'agtype' casting to JSON, ARRAY, any string is really 
needed** 
   
   
   Second the query that descirbed in document you sent is like that
   ```
   SELECT *
   FROM cypher('graph_name', $$
   WITH {listKey: [{inner: 'Map1'}, {inner: 'Map2'}], mapKey: {i: 0}} as m
   RETURN m
   $$) AS (m agtype);
   ```
   but as I mentioned, It has same problem ; **two-times casting**
   after extracting the JSON data from Cypher, then we might cast it into 
'varchar' and 'json'(actually casting to proper json from agtype is 
complex.,you guys need use regular expression also to properly parse to 
json, ), and It's cost is too high to cast two-times...
   
   
   
   P.S. in the case of agtype that formed Json, I normally use the below method
   `replace(regexp_replace(**col**::varchar, '::[a-zA-Z0-9\[\]]+', '', 'g'), 
E'\"', '"')::jsonb;`
   I've researched for casting agtype into other datatype, but until now, It is 
at least fine to cast json
   
   
   **So I think agtype need many improvements in casting problem.**
   
   


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

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