Re: SQL/JSON: functions

Started by Andrew Alsupabout 7 years ago2 messages
#1Andrew Alsup
bluesbreaker@gmail.com

Attached 21st version of the patches.

I decided to include here patch 0000 with complete jsonpath

implementation (it

is a squash of all 6 jsonpath-v21 patches). I hope this will simplify

reviewing

and testing in cfbot.cputube.org.

I'd like to help in reviewing this patch. Please let me know if there's
something in particular I should focus on such as documentation,
functionality, or source. If not, I'll probably just proceed in that order.

Regards, Andy Alsup

#2Andrew Alsup
bluesbreaker@gmail.com
In reply to: Andrew Alsup (#1)

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;