Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qhbs1-003e5l-PX for pgsql-hackers@arkaria.postgresql.org; Sat, 16 Sep 2023 20:26:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qhbs0-000oKR-8y for pgsql-hackers@arkaria.postgresql.org; Sat, 16 Sep 2023 20:26:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qhbrz-000oK1-K8 for pgsql-hackers@lists.postgresql.org; Sat, 16 Sep 2023 20:26:23 +0000 Received: from pb-smtp2.pobox.com ([64.147.108.71]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qhbrw-004wdj-Kz for pgsql-hackers@lists.postgresql.org; Sat, 16 Sep 2023 20:26:22 +0000 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 7F6AB1A516C; Sat, 16 Sep 2023 16:26:19 -0400 (EDT) (envelope-from david@justatheory.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h= content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; s=sasl; bh=Pl4/aqvcLagXLB7jkRQ1FJILZK 3nbRXHI3g/2SGBCl4=; b=xIfBZQTi9lvZJN22qVQc3rbs5rkiCTAs0904WSYvbg gjPCO5y77POsPhK4Ih0MmdN+hkY/nVBzUDiLZBQHadQ9sbs/gQ0AuaadujQ7nYYW Aw47QcQlOCZ4nl8xLx2V66nUYgylOgs7Hp1Efeiq86cbwrzcGOblGr8M4xWebLZQ E= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 788981A516A; Sat, 16 Sep 2023 16:26:19 -0400 (EDT) (envelope-from david@justatheory.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=justatheory.com; h=content-type:mime-version:subject:from:in-reply-to:date:cc:message-id:references:to; s=2016-12.pbsmtp; bh=Pl4/aqvcLagXLB7jkRQ1FJILZK3nbRXHI3g/2SGBCl4=; b=ERbuFfq03KkbUvzyymvLV6loLEKqu3lf3LU43GD1boOZ6P/w04FNH9GtEqC1kJpiyRW6uMQ7dAsDtamJJiS4Y5YaIgfmEwjLrjsftFtC0/NSHYTEXEAjV+OYbNefJ8wse8JTcB8JRPpJ2zXgp/GTga4HZDdR8AnwYdzcODUA76A= Received: from smtpclient.apple (unknown [158.222.197.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id E050B1A5169; Sat, 16 Sep 2023 16:26:18 -0400 (EDT) (envelope-from david@justatheory.com) Content-Type: multipart/signed; boundary="Apple-Mail=_16510513-1918-4D74-AB67-23B8FDE389AE"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: JSON Path and GIN Questions From: "David E. Wheeler" X-Priority: 3 In-Reply-To: <133696180.303713.1694566807910@office.mailbox.org> Date: Sat, 16 Sep 2023 16:26:07 -0400 Cc: pgsql-hackers@lists.postgresql.org Message-Id: <7A19C6A6-DEB4-426D-BC6E-9F35A691E567@justatheory.com> References: <15DD78A5-B5C4-4332-ACFE-55723259C07F@justatheory.com> <133696180.303713.1694566807910@office.mailbox.org> To: Erik Wienhold X-Mailer: Apple Mail (2.3731.700.6) X-Pobox-Relay-ID: 4B147288-54CF-11EE-ADBF-25B3960A682E-76319746!pb-smtp2.pobox.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_16510513-1918-4D74-AB67-23B8FDE389AE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On Sep 12, 2023, at 21:00, Erik Wienhold wrote: >> If so, I=E2=80=99d like to submit a patch to the docs talking about = this, and >> suggesting the use of jsonb_path_query() to test paths to see if they = return >> a boolean or not. >=20 > +1 I=E2=80=99ve started work on this; there=E2=80=99s so much to learn! = Here=E2=80=99s a new example that surprised me a bit. Using the GPS = tracker example from the docs [1] loaded into a `:json` psql variable, = this output of this query makes perfect sense to me: david=3D# select jsonb_path_query(:'json', '$.track.segments.location[*] = ? (@ < 14)'); jsonb_path_query ------------------ 13.4034 13.2635 Because `[*]` selects all the values. This, however, I did not expect: david=3D# select jsonb_path_query(:'json', '$.track.segments.location ? = (@[*] < 14)'); jsonb_path_query ------------------ 13.4034 13.2635 (2 rows) I had expected it to return two single-value arrays, instead: [13.4034] [13.2635] It appears that the filter expression is doing some sub-selection, too. = Is that expected? Best, David [1]: = https://www.postgresql.org/docs/current/functions-json.html#FUNCTIONS-SQLJ= SON-PATH --Apple-Mail=_16510513-1918-4D74-AB67-23B8FDE389AE Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEd+KfmbOQis6ZycGGkt9idPjIgfEFAmUGD18ACgkQkt9idPjI gfH8fw/5AYmbLATrI4FzmUrwc6kt/SceyuArvDMLaiOKmJr/N/k/lmx9LF2Xo8Xj Hu0CI3vzB7QMwh7ZyN5OeNcYu8T9yM+UFlTeUOwDQGgu4Sw41CMKKxnnJrvgPYeZ MKy6yY6TnovK6ZzqgNJ33QhXbT465V2fW34V/+7xR2p9TsSVEwqXsQRcw+zQ3pv6 1kfypGu+VLcU5IBFrdgEyZ7jW9k+mclRu9eCJgYL0ePR9hDA1bzJNtW+5MDZJ44v 9P5tD5Sk513nXqAd1pqqTPTq+dTWIAdqQ7dCVb9JI0eMPtZbsToep0ijoVkQ0REW taML0E6xFrlyoIxEKBdIUirwMPlzBLBiyRMtV5ZbfqclnFyKJU6nJkivSabNUDTG /yDK+89jTMSsp8MUlPRahCm3PpqjKpwPJA4bKPe/FKLDLWKTyuPc+epHWYkBfmtB DZTquWO/czkSip6ibIQFNNFfQaUEkOliN6KDj2GUy+jvrDc7M0rITg7VdbzIV8OE 1wGlETlCOAVk0cAzaAo8FADkjs+F6VHeYfKpKaV0Ovs1tBerohqa6Gq9QlSiZ+FK Zd5B9jdL/eR6Dd/6TI31k+OrY5EHqKRoHQgLMWChqEElEy82BEw3R4XSzN9izbs9 FOsEJz7nuezhqlBKvcwqcHo/QbGI4tTO+kD1m7ufVF+gbpCh028= =J54C -----END PGP SIGNATURE----- --Apple-Mail=_16510513-1918-4D74-AB67-23B8FDE389AE--