strip nulls functions for json and jsonb

Lists: pgsql-hackers
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: strip nulls functions for json and jsonb
Date: 2014-10-03 23:23:37
Message-ID: 542F2FF9.8080200@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

As discussed recently, here is an undocumented patch for
json_strip_nulls and jsonb_strip_nulls.

cheers

andrew

Attachment Content-Type Size
jsonstripnulls.patch text/x-patch 14.6 KB

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-04 05:24:55
Message-ID: CAFj8pRBjqpwiK56m7eGZCm_jTjH34YSiu=J7BvxhXF14tr=RVQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi

2014-10-04 1:23 GMT+02:00 Andrew Dunstan <andrew(at)dunslane(dot)net>:

> As discussed recently, here is an undocumented patch for json_strip_nulls
> and jsonb_strip_nulls.
>

It is looking well

Regards

Pavel

>
> cheers
>
> andrew
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
>


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-16 20:12:11
Message-ID: CAFj8pRB2Xa=wxy_Eh_2DnLr05W1vGP+TwTGH5ueYOenJnYQ6aQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

I checked this patch.

1. There is a consensus we want this feature.

2. This patch implement just this mentioned feature. There is no objection
against design.

3. It is possible to apply this patch and compile without warnings.

4. I tested null stripping on large json, jsonb values without problems.

5. regress tests are enough

6. code is well formatted

Objections & questions:

1. missing documentation

2. I miss more comments related to this functions. This code is relative
simple, but some more explanation can be welcome.

3. why these functions are marked as "stable"?

Regards

Pavel

2014-10-04 1:23 GMT+02:00 Andrew Dunstan <andrew(at)dunslane(dot)net>:

> As discussed recently, here is an undocumented patch for json_strip_nulls
> and jsonb_strip_nulls.
>
> cheers
>
> andrew
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
>


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-26 18:59:34
Message-ID: 544D4496.8050307@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 10/16/2014 04:12 PM, Pavel Stehule wrote:
>
>
> 1. missing documentation
>
> 2. I miss more comments related to this functions. This code is
> relative simple, but some more explanation can be welcome.
>
> 3. why these functions are marked as "stable"?
>
>

New patch:

Docs added, functions marked immutable, more comments added.

cheers

andrew

Attachment Content-Type Size
jsonstripnulls3.patch text/x-diff 16.6 KB

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-26 19:50:32
Message-ID: CAFj8pRCWCoXZiiytkvuNiuw=9-u6hXQeOO8qL4r3N1vqPo2u4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi

I have a question,

what is expected result of null strip of

{"a": {"b": null, "c", null"} }

?

2014-10-26 19:59 GMT+01:00 Andrew Dunstan <andrew(at)dunslane(dot)net>:

>
> On 10/16/2014 04:12 PM, Pavel Stehule wrote:
>
>>
>>
>> 1. missing documentation
>>
>> 2. I miss more comments related to this functions. This code is relative
>> simple, but some more explanation can be welcome.
>>
>> 3. why these functions are marked as "stable"?
>>
>>
>>
> New patch:
>
> Docs added, functions marked immutable, more comments added.
>
> cheers
>
> andrew
>


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-26 20:07:52
Message-ID: 544D5498.6080700@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 10/26/2014 03:50 PM, Pavel Stehule wrote:
> Hi
>
> I have a question,
>
> what is expected result of null strip of
>
> {"a": {"b": null, "c", null"} }
>
> ?
>

Please remember not to top-post.

The above is not legal json, so the answer would be an error.

cheers

andrew


From: Thom Brown <thom(at)linux(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-26 20:14:17
Message-ID: CAA-aLv4NCxR7fxZDt2eLJUvPV3ENP-uTmF_cBJsfMWR4TX7nsA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 26 October 2014 20:07, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

>
> On 10/26/2014 03:50 PM, Pavel Stehule wrote:
>
>> Hi
>>
>> I have a question,
>>
>> what is expected result of null strip of
>>
>> {"a": {"b": null, "c", null"} }
>>
>> ?
>>
>>
>
> Please remember not to top-post.
>
> The above is not legal json, so the answer would be an error.
>

I believe Pavel means:

{"a": {"b": null, "c": null} }

--
Thom


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Thom Brown <thom(at)linux(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-26 20:18:03
Message-ID: 544D56FB.3020308@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 10/26/2014 04:14 PM, Thom Brown wrote:
> On 26 October 2014 20:07, Andrew Dunstan <andrew(at)dunslane(dot)net
> <mailto:andrew(at)dunslane(dot)net>> wrote:
>
>
> On 10/26/2014 03:50 PM, Pavel Stehule wrote:
>
> Hi
>
> I have a question,
>
> what is expected result of null strip of
>
> {"a": {"b": null, "c", null"} }
>
> ?
>
>
>
> Please remember not to top-post.
>
> The above is not legal json, so the answer would be an error.
>
>
> I believe Pavel means:
>
> {"a": {"b": null, "c": null} }

This is the expected result:

andrew=# select json_strip_nulls('{"a": {"b": null, "c": null} }');
json_strip_nulls
------------------
{"a":{}}
(1 row)

It is NOT expected that we replace an empty object with NULL (and then
strip it if it's a field value of an outer level object).

cheers

andrew


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Thom Brown <thom(at)linux(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-26 20:22:32
Message-ID: CAFj8pRDH2gA8w3fX1wktZZbOJr7sdRfppZJSWJ5bTOf2MBbeMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2014-10-26 21:18 GMT+01:00 Andrew Dunstan <andrew(at)dunslane(dot)net>:

>
> On 10/26/2014 04:14 PM, Thom Brown wrote:
>
>> On 26 October 2014 20:07, Andrew Dunstan <andrew(at)dunslane(dot)net <mailto:
>> andrew(at)dunslane(dot)net>> wrote:
>>
>>
>> On 10/26/2014 03:50 PM, Pavel Stehule wrote:
>>
>> Hi
>>
>> I have a question,
>>
>> what is expected result of null strip of
>>
>> {"a": {"b": null, "c", null"} }
>>
>> ?
>>
>>
>>
>> Please remember not to top-post.
>>
>> The above is not legal json, so the answer would be an error.
>>
>>
>> I believe Pavel means:
>>
>> {"a": {"b": null, "c": null} }
>>
>
> This is the expected result:
>
> andrew=# select json_strip_nulls('{"a": {"b": null, "c": null} }');
> json_strip_nulls
> ------------------
> {"a":{}}
> (1 row)
>
>
> It is NOT expected that we replace an empty object with NULL (and then
> strip it if it's a field value of an outer level object).
>

ok,

This case should be in regress test probably

Thank you

Pavel

>
> cheers
>
> andrew
>
>


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Thom Brown <thom(at)linux(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-26 20:57:09
Message-ID: 544D6025.4050001@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 10/26/2014 04:22 PM, Pavel Stehule wrote:
>
>
> 2014-10-26 21:18 GMT+01:00 Andrew Dunstan <andrew(at)dunslane(dot)net
> <mailto:andrew(at)dunslane(dot)net>>:
>
>
> On 10/26/2014 04:14 PM, Thom Brown wrote:
>
> On 26 October 2014 20:07, Andrew Dunstan <andrew(at)dunslane(dot)net
> <mailto:andrew(at)dunslane(dot)net> <mailto:andrew(at)dunslane(dot)net
> <mailto:andrew(at)dunslane(dot)net>>> wrote:
>
>
> On 10/26/2014 03:50 PM, Pavel Stehule wrote:
>
> Hi
>
> I have a question,
>
> what is expected result of null strip of
>
> {"a": {"b": null, "c", null"} }
>
> ?
>
>
>
> Please remember not to top-post.
>
> The above is not legal json, so the answer would be an error.
>
>
> I believe Pavel means:
>
> {"a": {"b": null, "c": null} }
>
>
> This is the expected result:
>
> andrew=# select json_strip_nulls('{"a": {"b": null, "c": null} }');
> json_strip_nulls
> ------------------
> {"a":{}}
> (1 row)
>
>
> It is NOT expected that we replace an empty object with NULL (and
> then strip it if it's a field value of an outer level object).
>
>
> ok,
>
> This case should be in regress test probably
>
>

Patch attached.

cheers

andrew

Attachment Content-Type Size
jsonstripnulls4.patch text/x-diff 17.6 KB

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Thom Brown <thom(at)linux(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-27 10:05:11
Message-ID: CAFj8pRBcPPvft94-D8azv9m1Nr35hyq41_+omYb9ngHzTJxMpg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi

I am sending a final review of this patch:

0. this patch implements null fields stripping. It does exactly what was
proposed and we would to have this feature in core. It is requested feature
for JSON types.

1. there is no problem with patch apply and with compilation - one warning
is fixed in attachments

2. code is relative small and clean, I have no any objection

3. there is necessary regress tests and related documentation.

I have no any objection - this patch is ready for commiter.

Thank you for patch

Regards

Pavel

2014-10-26 21:57 GMT+01:00 Andrew Dunstan <andrew(at)dunslane(dot)net>:

>
> On 10/26/2014 04:22 PM, Pavel Stehule wrote:
>
>>
>>
>> 2014-10-26 21:18 GMT+01:00 Andrew Dunstan <andrew(at)dunslane(dot)net <mailto:
>> andrew(at)dunslane(dot)net>>:
>>
>>
>> On 10/26/2014 04:14 PM, Thom Brown wrote:
>>
>> On 26 October 2014 20:07, Andrew Dunstan <andrew(at)dunslane(dot)net
>> <mailto:andrew(at)dunslane(dot)net> <mailto:andrew(at)dunslane(dot)net
>> <mailto:andrew(at)dunslane(dot)net>>> wrote:
>>
>>
>> On 10/26/2014 03:50 PM, Pavel Stehule wrote:
>>
>> Hi
>>
>> I have a question,
>>
>> what is expected result of null strip of
>>
>> {"a": {"b": null, "c", null"} }
>>
>> ?
>>
>>
>>
>> Please remember not to top-post.
>>
>> The above is not legal json, so the answer would be an error.
>>
>>
>> I believe Pavel means:
>>
>> {"a": {"b": null, "c": null} }
>>
>>
>> This is the expected result:
>>
>> andrew=# select json_strip_nulls('{"a": {"b": null, "c": null} }');
>> json_strip_nulls
>> ------------------
>> {"a":{}}
>> (1 row)
>>
>>
>> It is NOT expected that we replace an empty object with NULL (and
>> then strip it if it's a field value of an outer level object).
>>
>>
>> ok,
>>
>> This case should be in regress test probably
>>
>>
>>
> Patch attached.
>
> cheers
>
> andrew
>

Attachment Content-Type Size
jsonstripnulls5.patch text/x-patch 17.8 KB