Re: [Jsonpath] Suggestion for distinct semantics of the descendant segment

Carsten Bormann <cabo@tzi.org> Thu, 15 June 2023 15:29 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: jsonpath@ietfa.amsl.com
Delivered-To: jsonpath@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 70994C151084 for <jsonpath@ietfa.amsl.com>; Thu, 15 Jun 2023 08:29:17 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.899
X-Spam-Level:
X-Spam-Status: No, score=-6.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ul3kkwRt_d0c for <jsonpath@ietfa.amsl.com>; Thu, 15 Jun 2023 08:29:15 -0700 (PDT)
Received: from smtp.zfn.uni-bremen.de (smtp.zfn.uni-bremen.de [IPv6:2001:638:708:32::21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id DA9E1C151082 for <jsonpath@ietf.org>; Thu, 15 Jun 2023 08:29:14 -0700 (PDT)
Received: from [192.168.217.124] (p548dc15c.dip0.t-ipconnect.de [84.141.193.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4QhmRX21BlzDCcp; Thu, 15 Jun 2023 17:29:12 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <Pr0_j5dkBVtKvMZK4ljLjmqjl-kW3M_rgNWE_uRA_A_AMoy43rBwzD1hXl4gSbDvkH5svVDAGpqO2mKevIdBPJznYyDwRLzwpJnmUET2Opw=@gienieczko.com>
Date: Thu, 15 Jun 2023 17:29:11 +0200
Cc: Greg Dennis <gregsdennis=40yahoo.com@dmarc.ietf.org>, "jsonpath@ietf.org" <jsonpath@ietf.org>, Filip Murlak <fmurlak@mimuw.edu.pl>, Charles Paperman <charles.paperman@univ-lille.fr>
X-Mao-Original-Outgoing-Id: 708535751.854848-fe32b63a9527feb8a13bdcfe6cfa110d
Content-Transfer-Encoding: quoted-printable
Message-Id: <FBE5B8CE-EF1D-4FCB-AA7F-A8F00F3DE682@tzi.org>
References: <DvRycFACMe-W8VEmLECGuEoLlvYOO8v48rW_3UDP1zL_R5D6htvzCxbdK-Nb-dInnL2WhcyI-yThsbCsQmqVr9IAGTUcBX1bMKIGTyBvz0o=@gienieczko.com> <SIx69Gmn_5bZBrt5XJ4LYnYaiP7JqVRyL3yHLHxGU7Zl3KLHK--Z9-qeMEciG3lHrIvYd9CAc2Ojf2j9ODMtrQ1zu-9D1ft20NCmCha5xbs=@gienieczko.com> <1547223928.66151.1686778005429@mail.yahoo.com> <404530738.91917.1686785247548@mail.yahoo.com> <Pr0_j5dkBVtKvMZK4ljLjmqjl-kW3M_rgNWE_uRA_A_AMoy43rBwzD1hXl4gSbDvkH5svVDAGpqO2mKevIdBPJznYyDwRLzwpJnmUET2Opw=@gienieczko.com>
To: Mateusz Gienieczko <mat=40gienieczko.com@dmarc.ietf.org>
X-Mailer: Apple Mail (2.3608.120.23.2.7)
Archived-At: <https://mailarchive.ietf.org/arch/msg/jsonpath/z2V_DSrrvHEpmgXJTIkwMcPKxDc>
Subject: Re: [Jsonpath] Suggestion for distinct semantics of the descendant segment
X-BeenThere: jsonpath@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: A summary description of the list to be included in the table on this page <jsonpath.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/jsonpath>, <mailto:jsonpath-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/jsonpath/>
List-Post: <mailto:jsonpath@ietf.org>
List-Help: <mailto:jsonpath-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/jsonpath>, <mailto:jsonpath-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 15 Jun 2023 15:29:17 -0000

Mi Mateusz,

thank you again for your continued input.

> On 2023-06-15, at 15:47, Mateusz Gienieczko <mat=40gienieczko.com@dmarc.ietf.org> wrote:
> 
> Signed PGP part
> 
>> We don't have any precedent for function selectors at this time, and I'm not sure what the syntax would be in the context of the path.
> 
> This might not generalize well enough to be put into any place in the path. But limiting this to be a top-level function would probably enough. I cannot come up with a non-contrived example for a query that a user would want to give distinct nodes in one place and non-distinct in another.
> 
> So, the proposal would be to have the ability to write a query of form `func(query)`. Of the top of my head, a modifier like count(q)​, returning number of nodes matched, would also be useful.

We need to be careful about completely leaving the current structure:  Right now results of queries are always nodelists of nodes that are in the initial query argument.  Count(q) isn’t.

We have been calling functionality of this kind “transformation”, as opposed to the “selection” functionality we have now.  “Projection” of course can be a form of “transformation” and has also been asked for (give me those objects, but with all members deleted except these two).

Reducing nodelists to distinct entries definitely is selection and would cause none of this pain.

> However, the main gripe here is that (let's call them) distinct descendant semantics are not even allowed in any way in the current spec. 

I’m not sure I’m reading you right, but we cannot “allow” that behavior without creating interoperability problems.  We would have to specify it.

> […]
>> I think the idea for a "distinct" operator `!` that can be appended to any selector is pretty neat, though.  This would also be applicable to cases like `$['a','a']!`.
> 
> That case is one more that might cause non-linear result sizes, but we deemed it not an issue simply because it's silly :)

We generally try to come up with short examples demonstrating a specific effect, even if they are silly.  So this is not a “motivating” example, just a “demonstrating” one.

So you did generate a “motivating” example:

> $..['a', *[@?.x]]​
[…]
>  I can imagine someone wishing for distinct semantics here, however.

I can, too.  But not distinct semantics for this example, but a way to specify distinct semantics.

See my previous message for why I don’t think we should do this now.
To be clear, this my opinion is not cast in concrete.

Grüße, Carsten