Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBYad-0003gs-Vv for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Nov 2016 02:56:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cBYac-0002D0-Gz for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Nov 2016 02:56:14 +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 1cBYaa-0002Cr-Oi for pgsql-hackers@postgresql.org; Tue, 29 Nov 2016 02:56:12 +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 1cBYaS-0000Kd-K8 for pgsql-hackers@postgresql.org; Tue, 29 Nov 2016 02:56:11 +0000 Received: from homiemail-a90.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a90.g.dreamhost.com (Postfix) with ESMTP id F3E1DA005A13; Mon, 28 Nov 2016 18:56:01 -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=6etWGfAzqVI7NU 6xjzUhVGAxBHs=; b=JYA+gF7a+jKdUEAdF41o9Z/yZ74fDDAEvQbKA2xbBLGEO4 F3IbFiLWd18zRqktvMyhlSYY6DSfJtkRQX7Wvl0i75cnWpDgC/MLuFFiUcnRrCD8 GMgqQV2eF8hGHg1aoRg7whuxYOMlyMfQ9Zvld83/Vtih6AoA1fre6v32nV0p0= 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 5D81CA005A12; Mon, 28 Nov 2016 18:56:01 -0800 (PST) Date: Mon, 28 Nov 2016 20:55:59 -0600 From: Nico Williams To: Christian Convey Cc: Pavel Stehule , David Fetter , PostgreSQL Hackers , Tom Lane Subject: Re: Tackling JsonPath support Message-ID: <20161129025556.GC24797@localhost> References: <20681.1479057226@sss.pgh.pa.us> <20161128162639.GB27143@fetter.org> <20161128192343.GD11117@localhost> <20161129022623.GB24797@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 06:38:55PM -0800, Christian Convey wrote: > On Mon, Nov 28, 2016 at 6:26 PM, Nico Williams > wrote: > > > > Thanks for the explanation. It sounds like your original point was NOT > that json-path isn't sufficient for "${specific use X}". The only uses of SQL w/ JSON I've seen so far in live action are to implement EAV schemas on PostgreSQL. Since PostgreSQL lacks an ANY type... using the hstore or jsonb to store data that would otherwise require an ANY type is the obvious thing to do. Naturally this use doesn't need deeply nested JSON data structures, so even JSONPath is overkill for it! However, there are use cases I can imagine: - generating complex JSON from complex (e.g., recursive) SQL data where the desired JSON "schema" is not close to the SQL schema I've used jq a *lot* to convert schemas. I've also use XSLT for the same purpose. I've also used SQL RDBMSes and jq together a fair bit, either having jq consume JSON documents to output INSERT and other statements, or having a SQL application output JSON that I then convert to an appropriate schema using jq. Naturally I can keep using these two tools separately. There's not much to gain from integrating them for this particular sort of use-case. - handling JSON documents with very loose schemata, perhaps arbitrary JSON documents, embedded in a SQL DB I've not needed to do this much, so I have no specific examples. But, of course, one reason I've not needed to do this is that today it kinda can't be done with enough expressivity. There are many use-cases for general-purpose programming languages, and even for very widely-applicable domain-specific programming language. It's especially difficult to name a specific use-case for a language that doesn't exist -- in this case that would be SQL + (jq and/or JSONPath). > Instead, your point was that jq seems to have many advantages over > json-path in general, and therefore PG should offer jq instead or, or in > addition to, json-path. > > Is that what you're saying? Roughly, yes. The distinct advantage is that jq is much more general and expressive, not unlike SQL itself. > > Hmm? > > Context: The reason I'm trying to work on a json-path implementation is > that Pavel Stehule suggested it as a good first PG-hacking project for me. > At the time, it sounded like he had a use for the feature. I see. I understand that. If you've already made a significant investment, then I don't blame you for not wanting to risk it. On the other hand, if melding jsonb and jq happens to be easy, then you'll get much more bang from it for your investment. Naturally, you do what you prefer, and if the reality on the ground is JSONPath, then so be it. If I had time and felt sufficiently strongly, I'd contribute jq integration; as it is I don't, and beggars can't be choosers. Nico -- -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers