Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hQLhf-0007Xb-NR for pgsql-hackers@arkaria.postgresql.org; Tue, 14 May 2019 00:53:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hQLhe-00045N-FM for pgsql-hackers@arkaria.postgresql.org; Tue, 14 May 2019 00:53:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hQLhe-00045G-0p for pgsql-hackers@lists.postgresql.org; Tue, 14 May 2019 00:53:58 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hQLhb-0005JL-Gr for pgsql-hackers@postgresql.org; Tue, 14 May 2019 00:53:56 +0000 Received: by mail-qt1-x832.google.com with SMTP id d13so9950620qth.5 for ; Mon, 13 May 2019 17:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=rqL5mhF5mXfEH7j2DxKeLOzjDTaPYS6gCR9aSUwKgxo=; b=BIX/PF/MezA0ZZU1vuDOgj3CA5LWfsoN8sWHwzFtQaEHtxq4HT7mpwcHzIb7TqauTw eN9GoKaQaXnO4LCd6XYwTFTJ+uJEbw+JKg4BtMbymdHOLP3GtpsnzH94ERnMXJiEMlnC rnesxFv8akcyRmEyMYONmi4vUD8tzJ7iM8tYSa2jU/St3CLpbucg9vb4rKK44DqczUs5 HO7MbvIqWqwTSdqfrEDphbAi/r6GuMB84dDXxpJz70PAF04wnhzGVjIe6P9rZ2DcyaFz HEfu1HbY6okpcasBi9AbfuIA+MR2ng7P7B9+kZiB945VzJoZutbKD6ziTnEPTpO75Nxu fmqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=rqL5mhF5mXfEH7j2DxKeLOzjDTaPYS6gCR9aSUwKgxo=; b=oYoL6J1jdKMugaFhJPo0YC39yaPU5bpjLfOJINghXHSYty0LNt6JtCEFlgdGeFa0ce 1sFuRqSH4XK3GCgypftz32aqEP+1ueNnCny5ZDnyhBPBMGXkAhhUywmBFsCTs62W022P BTDq45vUDDiPsYseC5tO5nDPcTdCTKWiMfn3CVlnIpYR5G+9oEUYt44GHi23uhBL0S/L 6mgcadfsRxuq1ZX4AhPPOsYXeUhrwJNCaMFpQ1Tq4YIsaTU/vDqQBbfbuc9QgBVP5eA7 y3F5UTiVWIpCF/biHxWi+6eCiH9GvcUk2Y3KgwSDMqX0Wa/cn+RRvC6x/UZKyueWpEd0 8iDA== X-Gm-Message-State: APjAAAVF8WhUDYoJ1CPhrG81oIooSBUKt7/ye7iXDFNsAALv0Zly3+b0 Z1eWHk+3wCGe7uXMsRXh0cI= X-Google-Smtp-Source: APXvYqz/Yx6J/lvOaNaJrdLBfHyqGVyPKlssQJfktvZaZZPnMWIelPglnyIw8C9qYktgpdLNpSMzSw== X-Received: by 2002:ac8:5418:: with SMTP id b24mr26574180qtq.150.1557795233831; Mon, 13 May 2019 17:53:53 -0700 (PDT) Received: from [192.168.2.78] (c-73-201-119-74.hsd1.md.comcast.net. [73.201.119.74]) by smtp.gmail.com with ESMTPSA id f21sm6234906qkl.72.2019.05.13.17.53.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 17:53:53 -0700 (PDT) Subject: Re: Re: SQL/JSON: functions To: Nikita Glukhov , PostgreSQL-development Cc: Andres Freund , Dmitry Dolgov <9erthalion6@gmail.com>, Pavel Stehule , Oleg Bartunov , Alexander Korotkov , Michael Paquier , Simon Riggs , Andrew Dunstan References: <6862ba8f-70bf-6dd8-5651-5d9050c8f4de@postgrespro.ru> <579f9020-7844-617c-20db-a04e87125983@postgrespro.ru> <20190216051239.wvhizo3hg2lwqyzh@alap3.anarazel.de> <70d2bf4f-f932-15f3-4037-90acce48a3b6@postgrespro.ru> <8eecd3e0-8e34-85d0-04f2-77fb8da29d9e@postgrespro.ru> From: Andrew Alsup Message-ID: Date: Mon, 13 May 2019 20:53:51 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <8eecd3e0-8e34-85d0-04f2-77fb8da29d9e@postgrespro.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/5/19 5:35 PM, Nikita Glukhov wrote: > Attached 36th version of the patches rebased onto jsonpath v36. While testing this patch a found a few issues: [1] I was not able to apply the patch to the current HEAD. However, it applies cleanly to commit: e988878f85 (NOTE: I did not investigate which commit between e988878f85 and HEAD caused problems). [2] JsonPath array slicing does not work. I'm not aware of a comprehensive list of JsonPath features/syntax that is targeted for support; however, I did try various forms of array slicing, which don't currently work. Here are a few examples: The input document is the same in each example. {   "a1": 123,   "b1": "xxx",   "c1": {     "a2": 456,     "b2": "yyy",     "c2": [       {"a3": 777, "b3": "7z"},       {"a3": 888, "b3": "8z"}     ]   } } array wildcard selector [*] works: $.c1.c2[*].b3 # select json_path_query('{"a1": 123, "b1": "xxx", "c1": {"a2": 456, "b2": "yyy", "c2": [{"a3": 777, "b3": "7z"},{"a3": 888, "b3": "8z"}]}}'::json, '$.c1.c2[*].b3'::jsonpath);  json_path_query -----------------  "7z"  "8z" (2 rows) array index selector [0] works: $.c1.c2[0].b3 jsonpatch=# select json_path_query('{"a1": 123, "b1": "xxx", "c1": {"a2": 456, "b2": "yyy", "c2": [{"a3": 777, "b3": "7z"},{"a3": 888, "b3": "8z"}]}}'::json, '$.c1.c2[0].b3'::jsonpath);  json_path_query -----------------  "7z" (1 row) array slicing [0:], [:1], and [0:1] do not work:$.c1.c2[0:].b3 # select json_path_query('{"a1": 123, "b1": "xxx", "c1": {"a2": 456, "b2": "yyy", "c2": [{"a3": 777, "b3": "7z"},{"a3": 888, "b3": "8z"}]}}'::json, '$.c1.c2[0:].b3'::jsonpath); 2019-05-13 20:47:48.740 EDT [21856] ERROR:  bad jsonpath representation at character 147 2019-05-13 20:47:48.740 EDT [21856] DETAIL:  syntax error, unexpected ':', expecting ',' or ']' at or near ":" 2019-05-13 20:47:48.740 EDT [21856] STATEMENT:  select json_path_query('{"a1": 123, "b1": "xxx", "c1": {"a2": 456, "b2": "yyy", "c2": [{"a3": 777, "b3": "7z"},{"a3": 888, "b3": "8z"}]}}'::json, '$.c1.c2[0:].b3'::jsonpath); ERROR:  bad jsonpath representation LINE 1: ...7, "b3": "7z"},{"a3": 888, "b3": "8z"}]}}'::json, '$.c1.c2[0...                                                              ^ DETAIL:  syntax error, unexpected ':', expecting ',' or ']' at or near ":"