Re: SQL/JSON: functions - Mailing list pgsql-hackers

From Andrew Alsup
Subject Re: SQL/JSON: functions
Date
Msg-id 8b75b660-9ea3-adbe-951c-2aa3a5f1801f@gmail.com
Whole thread Raw
In response to Re: SQL/JSON: functions  (Andrew Alsup <bluesbreaker@gmail.com>)
List pgsql-hackers
 > Attached patches implementing all SQL/JSON functions excluding 
JSON_TABLE:
 >
 > JSON_OBJECT()
 > JSON_OBJECTAGG()
 > JSON_ARRAY()
 > JSON_ARRAYAGG()
 >
 > JSON_EXISTS()
 > JSON_VALUE()
 > JSON_QUERY()

Sorry if this is a stupid question, but is this patch intended to 
implement any SQL/JSON functions? I'm basing this question on the 
original patch post (quoted above). The patch appears to be focused 
exclusively on "jsonpath expressions". I only ask because I think I 
misinterpreted and spent some time wondering if I had missed a patch file.

So far, the jsonpath docs are very readable; however, I think a few 
complete examples (full SELECT statements) of using jsonpath expressions 
would be helpful to someone new to this technology. Does postgresql 
provide a sample schema, similar to the Or*cle scott/tiger (emp/dept) 
schema, we could use for examples? Alternatively, we could reference 
something mentioned at 
https://wiki.postgresql.org/wiki/Sample_Databases. I think it would be 
nice if all the docs referenced the same schema, when possible.

For tests, would it be helpful to have some tests that 
demonstrate/assert equality between "jsonb operators" and "jsonpath 
expressions"? For example, using the existing regression test data the 
following should assert equality in operator vs. expression:

SELECT
   CASE WHEN jop_count = expr_count THEN 'pass' ELSE 'fail' END
FROM
   (
     -- jsonb operator
     SELECT count(*)
     FROM testjsonb
     WHERE j->>'abstract' LIKE 'A%'
   ) as jop_count,
   (
     -- jsonpath expression
     SELECT count(*)
     FROM testjsonb
     WHERE j @? '$.abstract ? (@ starts with "A")'
   ) as expr_count;



pgsql-hackers by date:

Previous
From: Kohei KaiGai
Date:
Subject: Re: add_partial_path() may remove dominated path but still in use
Next
From: Surafel Temesgen
Date:
Subject: Re: FETCH FIRST clause PERCENT option