Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nWOan-0004Zm-9K for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Mar 2022 20:25:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nWOam-0001WO-3e for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Mar 2022 20:25:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nWOal-0001WF-Pw for pgsql-hackers@lists.postgresql.org; Mon, 21 Mar 2022 20:25:27 +0000 Received: from ewsoutbound.kpnmail.nl ([195.121.94.169]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nWOaj-0002fv-03 for pgsql-hackers@lists.postgresql.org; Mon, 21 Mar 2022 20:25:27 +0000 X-KPN-MessageId: ffc4910c-a954-11ec-990f-005056abad63 Received: from smtp.kpnmail.nl (unknown [10.31.155.40]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id ffc4910c-a954-11ec-990f-005056abad63; Mon, 21 Mar 2022 21:25:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=content-type:from:to:subject:mime-version:date:message-id; bh=CKfupd3WjxW1xqLfRxP2LIB8MgXmVHt4VHQWALVlBVI=; b=uhVM0ivhG9Opwjo83E/JK0fUlyNwZB1mgcemBMzUdzKW+foOX7V+9UiyqGLPNUXQSe4fHAR6fUq2O WPpqaFAuDNe78nK0O+bAfY720hpXp1VqdFKVTFXRGBXbce0uSUcbFhhOXJzjQMEFHsgMyVMGL+b3DJ g5ElaNjRjM4a33bZpX+jreLvf6BwVdGsU4Pn+wOZ8eYm9DjIppSmD8MbNfiX8Q8Mrv4cQGFMxcZ513 YVI8UXbztDFlkANCcOpPjvq8n5k/tLEPrauE0dyFZWbTQ3agabQyqVBN1S70LnPOBbRdcLyDnrfF/I s5GELBxayegiuatQoU2qnrMHFHAbj6g== X-KPN-VerifiedSender: Yes X-CMASSUN: 33|Z4kzGnuc/A4+v+TznhAwIaaof724UoUxARoTjW/C4tEVNJGRqY42JVNvQ7FYUqe tzYuRo9zZa2+EeC1gPbcO8A== X-Originating-IP: 45.83.234.25 Received: from [192.168.178.20] (unknown [45.83.234.25]) by smtp.xs4all.nl (Halon) with ESMTPSA id 067db974-a955-11ec-b148-005056ab7584; Mon, 21 Mar 2022 21:25:24 +0100 (CET) Message-ID: <1ea50079-3184-9220-ed5c-7925e61c60de@xs4all.nl> Date: Mon, 21 Mar 2022 21:25:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: jsonpath syntax extensions Content-Language: en-US To: pgsql-hackers@lists.postgresql.org References: From: Erik Rijkers In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Op 21-03-2022 om 21:13 schreef Greg Stark: > Hm. Actually... These changes were split off from the JSON_TABLE > patches? Are they still separate or have they been merged into those > other patches since? I see the JSON_TABLE thread is getting more > comments do those reviews include these patches? > They are separate. FWIW, I've done all my JSON_PATH testing both without and with these syntax extensions (but I've done no code review.) I like these extensions but as you say -- there seems to be not much interest. Erik > On Mon, 21 Mar 2022 at 16:09, Greg Stark wrote: >> >> This patch seems to be getting ignored. Like David I'm a bit puzzled >> because it doesn't seem like an especially obscure or difficult patch >> to review. Yet it's been multiple years without even a superficial >> "does it meet the coding requirements" review let alone a design >> review. >> >> Can we get a volunteer to at least give it a quick once-over? I don't >> think it's ideal to be doing this in the last CF but neither is it >> very appetizing to just shift it to the next CF without a review after >> two years... >> >> On Thu, 27 Feb 2020 at 10:58, Nikita Glukhov wrote: >>> >>> Hi, hackers! >>> >>> Attached patches implement several useful jsonpath syntax extensions. >>> I already published them two years ago in the original SQL/JSON thread, >>> but then after creation of separate threads for SQL/JSON functions and >>> JSON_TABLE I forgot about them. >>> >>> A brief description of the patches: >>> >>> 1. Introduced new jsonpath modifier 'pg' which is used for enabling >>> PostgreSQL-specific extensions. This feature was already proposed in the >>> discussion of jsonpath's like_regex implementation. >>> >>> 2. Added support for raw jbvObject and jbvArray JsonbValues inside jsonpath >>> engine. Now, jsonpath can operate with JSON arrays and objects only in >>> jbvBinary form. But with introduction of array and object constructors in >>> patches #4 and #5 raw in-memory jsonb containers can appear in jsonpath engine. >>> In some places we can iterate through jbvArrays, in others we need to encode >>> jbvArrays and jbvObjects into jbvBinay. >>> >>> 3. SQL/JSON sequence construction syntax. A simple comma-separated list can be >>> used to concatenate single values or sequences into a single resulting sequence. >>> >>> SELECT jsonb_path_query('[1, 2, 3]', 'pg $[*], 4, 2 + 3'); >>> jsonb_path_query >>> ------------------ >>> 1 >>> 2 >>> 3 >>> 4 >>> 5 >>> >>> SELECT jsonb_path_query('{ "a": [1, 2, 3], "b": [4, 5] }', >>> 'pg ($.a[*], $.b[*]) ? (@ % 2 == 1)'); >>> jsonb_path_query >>> ------------------ >>> 1 >>> 3 >>> 5 >>> >>> >>> Patches #4-#6 implement ECMAScript-like syntax constructors and accessors: >>> >>> 4. Array construction syntax. >>> This can also be considered as enclosing a sequence constructor into brackets. >>> >>> SELECT jsonb_path_query('[1, 2, 3]', 'pg [$[*], 4, 2 + 3]'); >>> jsonb_path_query >>> ------------------ >>> [1, 2, 3, 4, 5] >>> >>> Having this feature, jsonb_path_query_array() becomes somewhat redundant. >>> >>> >>> 5. Object construction syntax. It is useful for constructing derived objects >>> from the interesting parts of the original object. (But this is not sufficient >>> to "project" each object in array, item method like '.map()' is needed here.) >>> >>> SELECT jsonb_path_query('{"b": 2}', 'pg { a : 1, b : $.b, "x y" : $.b + 3 }'); >>> jsonb_path_query >>> ------------------------------- >>> { "a" : 1, "b": 3, "x y": 5 } >>> >>> Fields with empty values are simply skipped regardless of lax/strict mode: >>> >>> SELECT jsonb_path_query('{"a": 1}', 'pg { b : $.b, a : $.a ? (@ > 1) }'); >>> jsonb_path_query >>> ------------------ >>> {} >>> >>> >>> 6. Object subscription syntax. This gives us ability to specify what key to >>> extract on runtime. The syntax is the same as ordinary array subscription >>> syntax. >>> >>> -- non-existent $.x is simply skipped in lax mode >>> SELECT jsonb_path_query('{"a": "b", "b": "c"}', 'pg $[$.a, "x", "a"]'); >>> jsonb_path_query >>> ------------------ >>> "c" >>> "b" >>> >>> SELECT jsonb_path_query('{"a": "b", "b": "c"}', 'pg $[$fld]', '{"fld": "b"}'); >>> jsonb_path_query >>> ------------------ >>> "c" >>> >>> -- >>> Nikita Glukhov >>> Postgres Professional: http://www.postgrespro.com >>> The Russian Postgres Company >> >> >> >> -- >> greg > > >