Re: SQL/JSON: functions

From: Andrew Alsup <bluesbreaker(at)gmail(dot)com>
To: Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Cc: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Oleg Bartunov <obartunov(at)postgrespro(dot)ru>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
Subject: Re: SQL/JSON: functions
Date: 2019-01-04 05:13:37
Message-ID: 8b75b660-9ea3-adbe-951c-2aa3a5f1801f@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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;

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2019-01-04 06:10:05 BUG #15572: Misleading message reported by "Drop function operation" on DB with functions having same name
Previous Message Kohei KaiGai 2019-01-04 04:46:27 Re: add_partial_path() may remove dominated path but still in use