Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBY9I-0002gT-HT for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Nov 2016 02:28:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cBY9H-00088b-Sa for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Nov 2016 02:27:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cBY7s-0006Zh-E8 for pgsql-hackers@postgresql.org; Tue, 29 Nov 2016 02:26:32 +0000 Received: from sub4.mail.dreamhost.com ([69.163.253.135] helo=homiemail-a90.g.dreamhost.com) by magus.postgresql.org with esmtps (TLS1.1:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cBY7p-0008FE-OT for pgsql-hackers@postgresql.org; Tue, 29 Nov 2016 02:26:31 +0000 Received: from homiemail-a90.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a90.g.dreamhost.com (Postfix) with ESMTP id 16109A005A13; Mon, 28 Nov 2016 18:26:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=cryptonector.com; bh=6eTaPVllAVYTfV BuBlOSzKEhiAk=; b=LkVmq/A2A252fpOXYBkYJm8WzVXZgtki/cTowvxylLEFuY B7NZ8rAUFyxozyDQbKkxwGcOl1bL7QupRC0vqQgXc++oCQYmXHox3P/v7OmyT+FS +MeWoj58UHiB00nu6s7/yNr6NG0A1+6EdbV8Hl+2bvsu+Fz1lCLhWzUM4Fd+I= Received: from localhost (cpe-70-123-158-140.austin.res.rr.com [70.123.158.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by homiemail-a90.g.dreamhost.com (Postfix) with ESMTPSA id 6070CA005A12; Mon, 28 Nov 2016 18:26:26 -0800 (PST) Date: Mon, 28 Nov 2016 20:26:24 -0600 From: Nico Williams To: Christian Convey Cc: Pavel Stehule , David Fetter , PostgreSQL Hackers , Tom Lane Subject: Re: Tackling JsonPath support Message-ID: <20161129022623.GB24797@localhost> References: <20681.1479057226@sss.pgh.pa.us> <20161128162639.GB27143@fetter.org> <20161128192343.GD11117@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Pg-Spam-Score: -1.5 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Mon, Nov 28, 2016 at 05:50:40PM -0800, Christian Convey wrote: > On Mon, Nov 28, 2016 at 11:23 AM, Nico Williams > wrote: > ... > > JSON Path is not expressive enough (last I looked) and can be mapped > > onto jq if need be anyways. > > Hi Nico, > > Could you please clarify what you mean by "not expressive enough"? jq is a functional language that has these and other features: - recursion - generators - lazy evaluation (of sorts) - path expressions - math functionality (libm, basically) - reduction - functions - and other things (jq does not have higher-order functions in that functions cannot return functions and functions are not values, though it does have closures.) jq is and feels a lot like a SQL, but for JSON. > I ask because I've been struggling to identify clear requirements for the > json-path functionality I'm trying to provide. It sounds like perhaps you > have something concrete in mind. SQL imposes structure on data. Recursion makes SQL structure looser in the sense that it may not be easy or possible to express certain desirable schema constraints in SQL terms without resorting to triggers, say. Storing documents in XML, JSON, or other such recursion-friendly formats (perhaps in semantically equivalent but query-optimized forms) is also a way to avoid strict structure (thus one needs schema validators for XML, for example). Less rigid schema constraints do not and should not preclude powerful query languages. One could convert such documents to a SQL EAV schema, if one has an RDBMS with an ANY type (e.g., something like SQLite3's duck typing), and then use SQL to query them. But that may be more difficult to use than a SQL with support for XML/JSON/... and query sub-languages for those. SQL is very powerful. One might like to have similarly powerful, format-specific query languages for documents stored in XML, JSON, etcetera, in a SQL RDBMS. jq is such a language, for JSON documents. Ditto XPath/XSLT, for XML. While XPath is expressive and compact, XSLT is rather verbose; jq is as expressive as XSLT, but with the compact verbosity of XPath. > Since I myself have no need currently for this functionality, I'm left > guessing about hypothetical users of it. My current mental model is: That's a bit like asking what is the use for SQL :^) The point is that SQL is a powerful query language, and so is jq. Each is appropriate to its own domain; both could be used together. > (a) Backend web developers. AFAICT, their community has mostly settled on > the syntax/semantics proposed by Stefan Groessner. It would probably be > unkind for PG's implementation to deviate from that without a good reason. I can't speak for the community. I wouldn't take it personally that jq be not chosen, nor any other proposal of mine. If it's politically easier, then do that. > (b) PG hackers who will eventually implement the ISO SQL standard > operators. In the standards-committee meeting notes I've seen, it seemed > to me that they were planning to define some operators in terms of > json-path expression. So it would probably be good if whatever json-path > function I implement turns out to comply with that standard, so that the > PG-hackers can use it as a building block for their work. These could still be implemented (e.g., using jq itself). > (c) Pavel. (I'm still somewhat unclear on what has him interested in this, > and what his specific constraints are.) Hmm? Nico -- -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers