Re: Re: proposal: ignore null fields in not relation type composite type based constructors

Lists: pgsql-hackers
From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-05-25 05:53:15
Message-ID: CAFj8pRA1KZt8v8Eo9r9zED25w3cfMm8n-_5+cySpPs0Xz-bYrQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

In Czech Postgres mailing list was user request for serialization to json
without null values.

He needs a similar behave like XMLFOREST has - it ignores NULLs

In some situations and conversions, when your table is +/- sparse matrix,
this request is valid

postgres=# select hstore(omega) from omega;
hstore
─────────────────────────────────
"a"=>"10", "b"=>"20", "c"=>NULL
"a"=>NULL, "b"=>"20", "c"=>"30"
(2 rows)

Proposed function

postgres=# select hstore(omega, ignore_nulls := true) from omega;
hstore
─────────────────────────────────
"a"=>"10", "b"=>"20"
"b"=>"20", "c"=>"30"
(2 rows)

What do you thinking about this proposal?

Regards

Pavel


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-06-28 15:42:58
Message-ID: CAFj8pRCizZwv2yFMCQs6bVGofaELPY7tQx4sZs_WT1FVwj+Q3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

I am sending small patch, that allows ignore nulls in row_to_json function.
It allow significant size reduction of generated JSON documents.

Regards

Pavel

2014-05-25 7:53 GMT+02:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:

> Hello
>
> In Czech Postgres mailing list was user request for serialization to json
> without null values.
>
> He needs a similar behave like XMLFOREST has - it ignores NULLs
>
> In some situations and conversions, when your table is +/- sparse matrix,
> this request is valid
>
> postgres=# select hstore(omega) from omega;
> hstore
> ─────────────────────────────────
> "a"=>"10", "b"=>"20", "c"=>NULL
> "a"=>NULL, "b"=>"20", "c"=>"30"
> (2 rows)
>
> Proposed function
>
> postgres=# select hstore(omega, ignore_nulls := true) from omega;
> hstore
> ─────────────────────────────────
> "a"=>"10", "b"=>"20"
> "b"=>"20", "c"=>"30"
> (2 rows)
>
> What do you thinking about this proposal?
>
> Regards
>
> Pavel
>
>

Attachment Content-Type Size
row_to_json_choosy.patch text/x-patch 7.5 KB

From: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-08-22 10:21:18
Message-ID: CAM2+6=UJDZDE+hcWO0sbh_DrdqiVuFrXs24HZ5CAXK396jshwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Pavel,

You have said that XMLFOREST has something which ignores nulls, what's that?
Will you please provide an example ?

I am NOT sure, but here you are trying to omit entire field from the output
when its value is NULL. But that will add an extra efforts at other end
which is using output of this. That application need to know all fields and
then need to replace NULL values for missing fields. However we have an
optional argument for ignoring nulls and thus we are safe. Application will
use as per its choice.

Well, apart from that, tried reviewing the patch. Patch was applied but make
failed with following error.

make[3]: Entering directory `/home/jeevan/pg_master/src/backend/catalog'
cd ../../../src/include/catalog && '/usr/bin/perl' ./duplicate_oids
3255
make[3]: *** [postgres.bki] Error 1

Please run unused_oids script to find unused oid.

However, I had a quick look over code changes. At first glance it looks
good. But still need to check on SQL level and then code walk-through.

Waiting for updated patch.

Thanks

--
Jeevan B Chalke
Principal Software Engineer, Product Development
EnterpriseDB Corporation
The Enterprise PostgreSQL Company


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-08-23 05:21:50
Message-ID: CAFj8pRCV_q+HTcQednVm6ctxa_tbw4U8+JwSRY-3N2BfbJmZ3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

2014-08-22 12:21 GMT+02:00 Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>:

> Hi Pavel,
>
> You have said that XMLFOREST has something which ignores nulls, what's
> that?
> Will you please provide an example ?
>

I was partially wrong - XMLFOREST ignore null always

postgres=# select xmlforest(10 as a,20 as b,null as c);
xmlforest
--------------------
<a>10</a><b>20</b>
(1 row)

so if you would to empty elements, you should to use xmlelement and
xmlconcat

postgres=# select xmlconcat(xmlforest(10 as a,20 as b), xmlelement(name c,
null));
xmlconcat
------------------------
<a>10</a><b>20</b><c/>
(1 row)

>
> I am NOT sure, but here you are trying to omit entire field from the output
> when its value is NULL. But that will add an extra efforts at other end
> which is using output of this. That application need to know all fields and
> then need to replace NULL values for missing fields. However we have an
> optional argument for ignoring nulls and thus we are safe. Application will
> use as per its choice.
>

with my patch, you can do decision - lot of REST services doesn't
distinguishes between empty and missing tag - and some developers prefer
remove empty tags due less size of message.

>
> Well, apart from that, tried reviewing the patch. Patch was applied but
> make
> failed with following error.
>
> make[3]: Entering directory `/home/jeevan/pg_master/src/backend/catalog'
> cd ../../../src/include/catalog && '/usr/bin/perl' ./duplicate_oids
> 3255
> make[3]: *** [postgres.bki] Error 1
>
> Please run unused_oids script to find unused oid.
>

it needs remastering

update in attachemnt

>
> However, I had a quick look over code changes. At first glance it looks
> good. But still need to check on SQL level and then code walk-through.
>
> Waiting for updated patch.
>

thank you for review

Regards

Pavel

>
> Thanks
>
> --
> Jeevan B Chalke
> Principal Software Engineer, Product Development
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
>

Attachment Content-Type Size
row_to_json_choosy-2.patch text/x-patch 7.5 KB

From: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-01 10:33:53
Message-ID: CAM2+6=WaTsNQEsPmu1+5hjvuwTTnCdgyFPyXURgJ95JNah0WkQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Pavel,

Patch does look good to me. And found no issues as such.

However here are my optional suggestions:

1. Frankly, I did not like name of the function "row_to_json_pretty_choosy".
Something like "row_to_json_pretty_ignore_nulls" seems better to me.

2. To use ignore nulls feature, I have to always pass pretty flag.
Which seems weired.

Since we do support named argument, can we avoid that?
No idea how much difficult it is. If we have a default arguments to this
function then we do not need one and two argument variations for this
function as well. And we can use named argument for omitting the required
one. Just a thought.

Rest looks good to me.

Thanks

--
Jeevan B Chalke
Principal Software Engineer, Product Development
EnterpriseDB Corporation
The Enterprise PostgreSQL Company


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-01 18:31:22
Message-ID: CAFj8pRAQus+8EoPup3crZAj_oLbG-EovM=Ea_REmMZp-qi_fkg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2014-09-01 12:33 GMT+02:00 Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>:

> Hi Pavel,
>
> Patch does look good to me. And found no issues as such.
>
> However here are my optional suggestions:
>
> 1. Frankly, I did not like name of the function
> "row_to_json_pretty_choosy".
> Something like "row_to_json_pretty_ignore_nulls" seems better to me.
>

should be - I have no better name

>
> 2. To use ignore nulls feature, I have to always pass pretty flag.
> Which seems weired.
>
> Since we do support named argument, can we avoid that?
> No idea how much difficult it is. If we have a default arguments to this
> function then we do not need one and two argument variations for this
> function as well. And we can use named argument for omitting the required
> one. Just a thought.
>

it needs a redesign of original implementation, we should to change API to
use default values with named parameters

but it doesn't help too much (although it can be readable little bit more)

instead row_to_json(x, false, true)

be

row_ro_json(x, ignore_null := true)

it is not too much work, but I need a names for parameters

Regards

Pavel

>
> Rest looks good to me.
>
>
> Thanks
>
> --
> Jeevan B Chalke
> Principal Software Engineer, Product Development
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
>


From: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-02 11:54:42
Message-ID: CAM2+6=Vw47fWV19vJ2E3tDHBGBnD1mUXXwkNWfsfWV8WtB-8Bg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Pavel,

it needs a redesign of original implementation, we should to change API to
> use default values with named parameters
>
> but it doesn't help too much (although it can be readable little bit more)
>
> instead row_to_json(x, false, true)
>
> be
>
> row_ro_json(x, ignore_null := true)
>
> it is not too much work, but I need a names for parameters
>

I have tried adding dummy names (a, b, c) in pg_proc entry you have added.
But that is not sufficient. We need to have default values provided to these
arguments to work row_ro_json(x, ignore_null := true) call.
It was not trivial. So I have not put much thought on that.

For name, I choose (row, pretty, ignore_nulls) or similar.

However it was my thought.
If it is too complex of not so useful then we can ignore it.

Thanks
--
Jeevan B Chalke
Principal Software Engineer, Product Development
EnterpriseDB Corporation
The Enterprise PostgreSQL Company


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-03 05:05:50
Message-ID: CAFj8pRBXWpuJ4APAKcDUAqJNWjUqq1rXZAcxUzRTzgrymkaOGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

2014-09-02 13:54 GMT+02:00 Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>:

> Hi Pavel,
>
> it needs a redesign of original implementation, we should to change API
>> to use default values with named parameters
>>
>> but it doesn't help too much (although it can be readable little bit more)
>>
>> instead row_to_json(x, false, true)
>>
>> be
>>
>> row_ro_json(x, ignore_null := true)
>>
>> it is not too much work, but I need a names for parameters
>>
>
> I have tried adding dummy names (a, b, c) in pg_proc entry you have added.
> But that is not sufficient. We need to have default values provided to
> these
> arguments to work row_ro_json(x, ignore_null := true) call.
> It was not trivial. So I have not put much thought on that.
>
> For name, I choose (row, pretty, ignore_nulls) or similar.
>
> However it was my thought.
> If it is too complex of not so useful then we can ignore it.
>

here is patch

Regards

Pavel

>
> Thanks
> --
> Jeevan B Chalke
> Principal Software Engineer, Product Development
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
>

Attachment Content-Type Size
row_to_json_ignorenull-2.patch text/x-patch 8.3 KB

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-03 05:06:34
Message-ID: CAFj8pRD6kVU17yf4yboEheOoLu5U6188M7iMTRgq70nfZYpfCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2014-09-03 7:05 GMT+02:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:

> Hello
>
>
> 2014-09-02 13:54 GMT+02:00 Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>:
>
> Hi Pavel,
>>
>> it needs a redesign of original implementation, we should to change API
>>> to use default values with named parameters
>>>
>>> but it doesn't help too much (although it can be readable little bit
>>> more)
>>>
>>> instead row_to_json(x, false, true)
>>>
>>> be
>>>
>>> row_ro_json(x, ignore_null := true)
>>>
>>> it is not too much work, but I need a names for parameters
>>>
>>
>> I have tried adding dummy names (a, b, c) in pg_proc entry you have added.
>> But that is not sufficient. We need to have default values provided to
>> these
>> arguments to work row_ro_json(x, ignore_null := true) call.
>> It was not trivial. So I have not put much thought on that.
>>
>> For name, I choose (row, pretty, ignore_nulls) or similar.
>>
>
I cannot use "row" because it is keyword - I used "rowval"

Regards

Pavel

>
>> However it was my thought.
>> If it is too complex of not so useful then we can ignore it.
>>
>
> here is patch
>
> Regards
>
> Pavel
>
>
>>
>> Thanks
>> --
>> Jeevan B Chalke
>> Principal Software Engineer, Product Development
>> EnterpriseDB Corporation
>> The Enterprise PostgreSQL Company
>>
>>
>


From: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-03 07:27:08
Message-ID: CAM2+6=VYnCNicuKTvkQp+TFEDe2JMOk9KjtrXcFjQePYm6J8pQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Pavel,

Here are few more comments on new implementation.

1.
/*
- * SQL function row_to_json(row)
+ * SQL function row_to_json(row record, pretty bool, ignore_nulls bool)
*/

In above comments, parameter name "row" should changed to "rowval".

2.
-DATA(insert OID = 3155 ( row_to_json PGNSP PGUID 12 1 0 0 0 f f f f
t f s 1 0 114 "2249" _null_ _null_ _null_ _null_ row_to_json _null_ _null_
_null_ ));
+DATA(insert OID = 3155 ( row_to_json PGNSP PGUID 12 1 0 0 0 f f f f
t f s 1 0 114 "2249 16 16" _null_ _null_ "{rowval,pretty,ignore_nulls}"
_null_ row_to_json _null_ _null_ _null_ ));

Number of arguments (pronargs) should be 3 now. However, when we create it
again with default values it gets updated. But still here we should not have
inconsistency.

3.
extern Datum row_to_json(PG_FUNCTION_ARGS);
extern Datum row_to_json_pretty(PG_FUNCTION_ARGS);
+extern Datum row_to_json_pretty_choosy(PG_FUNCTION_ARGS);
extern Datum to_json(PG_FUNCTION_ARGS);

With this new implementation, we have NOT added row_to_json_pretty_choosy()
function. So need to remove that added line. Also we have only one function
with default arguments and thus removed row_to_json_pretty() function as
well. Thus need to remove extern for that too.

4.
Can we have couple of test cases with named argument along with skipped
pretty parameter test?

Thanks

--
Jeevan B Chalke
Principal Software Engineer, Product Development
EnterpriseDB Corporation
The Enterprise PostgreSQL Company


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-03 07:55:16
Message-ID: CAFj8pRCzfTGXa9CZizVEaDWKpnYoUgEzTC9NhhALUMo6Mx_B3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi

2014-09-03 9:27 GMT+02:00 Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>:

> Hi Pavel,
>
> Here are few more comments on new implementation.
>
> 1.
> /*
> - * SQL function row_to_json(row)
> + * SQL function row_to_json(row record, pretty bool, ignore_nulls bool)
> */
>
> In above comments, parameter name "row" should changed to "rowval".
>
> 2.
> -DATA(insert OID = 3155 ( row_to_json PGNSP PGUID 12 1 0 0 0 f f f
> f t f s 1 0 114 "2249" _null_ _null_ _null_ _null_ row_to_json _null_
> _null_ _null_ ));
> +DATA(insert OID = 3155 ( row_to_json PGNSP PGUID 12 1 0 0 0 f f f
> f t f s 1 0 114 "2249 16 16" _null_ _null_ "{rowval,pretty,ignore_nulls}"
> _null_ row_to_json _null_ _null_ _null_ ));
>
> Number of arguments (pronargs) should be 3 now. However, when we create it
> again with default values it gets updated. But still here we should not
> have
> inconsistency.
>
> 3.
> extern Datum row_to_json(PG_FUNCTION_ARGS);
> extern Datum row_to_json_pretty(PG_FUNCTION_ARGS);
> +extern Datum row_to_json_pretty_choosy(PG_FUNCTION_ARGS);
> extern Datum to_json(PG_FUNCTION_ARGS);
>
> With this new implementation, we have NOT added row_to_json_pretty_choosy()
> function. So need to remove that added line. Also we have only one function
> with default arguments and thus removed row_to_json_pretty() function as
> well. Thus need to remove extern for that too.
>
> 4.
> Can we have couple of test cases with named argument along with skipped
> pretty parameter test?
>
>
>
done

Regards

Pavel

>
> Thanks
>
> --
> Jeevan B Chalke
> Principal Software Engineer, Product Development
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
>

Attachment Content-Type Size
help-variables-11.patch text/x-patch 20.7 KB

From: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-04 05:35:51
Message-ID: CAM2+6=VKy74mHi3+Tqfa16vTg-2Eku_vg2tx-pReRBOvLf=FXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Pavel,

You have attached wrong patch.

Thanks
--
Jeevan B Chalke
Principal Software Engineer, Product Development
EnterpriseDB Corporation
The Enterprise PostgreSQL Company


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-04 06:11:42
Message-ID: CAFj8pRDeHrXucUprJS4Qw=ahNZoPu-yRcxsMNj2YPwze8AoAog@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I am sory

too much patches

Regards

Pavel

2014-09-04 7:35 GMT+02:00 Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>:

> Hi Pavel,
>
> You have attached wrong patch.
>
>
> Thanks
> --
> Jeevan B Chalke
> Principal Software Engineer, Product Development
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
>

Attachment Content-Type Size
row_to_json_ignorenull-3.patch text/x-patch 9.8 KB

From: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-05 06:29:26
Message-ID: CAM2+6=U4+YOFAzVUfk+NJi65tDqYXtG8SBf9SwMqBy3QtA7T0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Sep 4, 2014 at 11:41 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
wrote:

> I am sory
>
> too much patches
>

:)

Patch looks good to me.
Marking "Ready for Committer".

Thanks

>
> Regards
>
> Pavel
>

--
Jeevan B Chalke
Principal Software Engineer, Product Development
EnterpriseDB Corporation
The Enterprise PostgreSQL Company


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-05 06:33:35
Message-ID: CAFj8pRDoQFiXq3+76ah9r4h0P9UESk3n3qUy4-ra1SXnB2fOEg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thank you

Regards

Pavel

2014-09-05 8:29 GMT+02:00 Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>:

>
>
>
> On Thu, Sep 4, 2014 at 11:41 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
>
>> I am sory
>>
>> too much patches
>>
>
> :)
>
> Patch looks good to me.
> Marking "Ready for Committer".
>
> Thanks
>
>
>>
>> Regards
>>
>> Pavel
>>
>
>
> --
> Jeevan B Chalke
> Principal Software Engineer, Product Development
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
>


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-08 03:48:38
Message-ID: 20140908034838.GZ16422@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Pavel, All,

* Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
> Thank you

I made a few minor adjustments, but the bigger issue (in my view) is
what to do about array_to_json_pretty- seems like we should do the same
there, no? Perhaps you could propose a new patch which incorporates my
minor changes and also removes array_to_json_pretty and makes
array_to_json take an optional argument?

Thoughts?

Thanks,

Stephen

Attachment Content-Type Size
row_to_json_ignorenull-4.patch text/x-diff 9.6 KB

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-08 04:16:53
Message-ID: CAFj8pRCBMOO6JURjO=3xEdNq8AcVrVinfAVQebTcg_C=2WZq5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi

2014-09-08 5:48 GMT+02:00 Stephen Frost <sfrost(at)snowman(dot)net>:

> Pavel, All,
>
> * Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
> > Thank you
>
> I made a few minor adjustments, but the bigger issue (in my view) is
> what to do about array_to_json_pretty- seems like we should do the same
> there, no? Perhaps you could propose a new patch which incorporates my
> minor changes and also removes array_to_json_pretty and makes
> array_to_json take an optional argument?
>

I though about it, and I am not sure. If somebody uses arrays as set, then
it can be good idea, when it is used as array, then you cannot to throw a
nulls from array.

I am thinking, so it is not necessary, because we can remove NULLs from
array simply via iteration over array (what is impossible for row fields)

CREATE OR REPLACE FUNCTION remove_null(anyarray)
RETURNS anyarray AS $$
SELECT ARRAY(SELECT a FROM unnest($1) g(a) WHERE a IS NOT NULL)
$$ LANGUAGE plpgsql;

or this function can be in core for general usage.

ignore_nulls in array_to_json_pretty probably is not necessary. On second
hand, the cost is zero, and we can have it for API consistency.

Regards

Pavel

>
> Thoughts?
>
> Thanks,
>
> Stephen
>


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-08 04:27:12
Message-ID: 20140908042712.GB16422@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
> ignore_nulls in array_to_json_pretty probably is not necessary. On second
> hand, the cost is zero, and we can have it for API consistency.

I'm willing to be persuaded either way on this, really. I do think it
would be nice for both array_to_json and row_to_json to be single
functions which take default values, but as for if array_to_json has a
ignore_nulls option, I'm on the fence and would defer to people who use
that function regularly (I don't today).

Beyond that, I'm pretty happy moving forward with this patch.

Thanks,

Stephen


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-08 07:02:57
Message-ID: CAFj8pRDd8BTAJ+nMoNwBAoxsr5aFa8yUAzEkWxo3OWjQnyKmtA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2014-09-08 6:27 GMT+02:00 Stephen Frost <sfrost(at)snowman(dot)net>:

> * Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
> > ignore_nulls in array_to_json_pretty probably is not necessary. On second
> > hand, the cost is zero, and we can have it for API consistency.
>
> I'm willing to be persuaded either way on this, really. I do think it
> would be nice for both array_to_json and row_to_json to be single
> functions which take default values, but as for if array_to_json has a
> ignore_nulls option, I'm on the fence and would defer to people who use
> that function regularly (I don't today).
>
> Beyond that, I'm pretty happy moving forward with this patch.
>

ok

Regards

Pavel

>
> Thanks,
>
> Stephen
>


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-11 06:45:37
Message-ID: CAFj8pRDpr7KwfuPsW4FJ80URpSQ3Zcquija+83KWhXFu1RoxFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Stephen

Can I help with something, it is there some open question?

Regards

Pavel

2014-09-08 6:27 GMT+02:00 Stephen Frost <sfrost(at)snowman(dot)net>:

> * Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
> > ignore_nulls in array_to_json_pretty probably is not necessary. On second
> > hand, the cost is zero, and we can have it for API consistency.
>
> I'm willing to be persuaded either way on this, really. I do think it
> would be nice for both array_to_json and row_to_json to be single
> functions which take default values, but as for if array_to_json has a
> ignore_nulls option, I'm on the fence and would defer to people who use
> that function regularly (I don't today).
>
> Beyond that, I'm pretty happy moving forward with this patch.
>
> Thanks,
>
> Stephen
>


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-11 12:29:47
Message-ID: 20140911122947.GA16422@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
> Can I help with something, it is there some open question?

I had been hoping for a more definitive answer regarding this option for
array_to_json, or even a comment about the change to row_to_json.
Andrew- any thoughts on this? (that's what the ping on IRC is for :).

Thanks,

Stephen

> 2014-09-08 6:27 GMT+02:00 Stephen Frost <sfrost(at)snowman(dot)net>:
> > * Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
> > > ignore_nulls in array_to_json_pretty probably is not necessary. On second
> > > hand, the cost is zero, and we can have it for API consistency.
> >
> > I'm willing to be persuaded either way on this, really. I do think it
> > would be nice for both array_to_json and row_to_json to be single
> > functions which take default values, but as for if array_to_json has a
> > ignore_nulls option, I'm on the fence and would defer to people who use
> > that function regularly (I don't today).
> >
> > Beyond that, I'm pretty happy moving forward with this patch.


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-11 15:46:48
Message-ID: 5411C3E8.504@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 09/11/2014 08:29 AM, Stephen Frost wrote:
> * Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
>> Can I help with something, it is there some open question?
> I had been hoping for a more definitive answer regarding this option for
> array_to_json, or even a comment about the change to row_to_json.
> Andrew- any thoughts on this? (that's what the ping on IRC is for :).

The change in row_to_json looks OK, I think. we're replacing an
overloading with use of default params, yes? That seems quite
reasonable, and users shouldn't notice the difference.

There might be a case for optionally suppressing nulls in array_to_json,
and it might work reasonably since unlike SQL arrays JSON arrays don't
have to be regular (if nested they are arrays of arrays, not
multi-dimensional single arrays). OTOH I'm not sure if it's worth doing
just for the sake of orthogonality. If someone wants it, then go for it.

cheers

andrew


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-11 18:10:35
Message-ID: 20140911181034.GE16422@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew,

* Andrew Dunstan (andrew(at)dunslane(dot)net) wrote:
> On 09/11/2014 08:29 AM, Stephen Frost wrote:
> >* Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
> >>Can I help with something, it is there some open question?
> >I had been hoping for a more definitive answer regarding this option for
> >array_to_json, or even a comment about the change to row_to_json.
> >Andrew- any thoughts on this? (that's what the ping on IRC is for :).
>
> The change in row_to_json looks OK, I think. we're replacing an
> overloading with use of default params, yes? That seems quite
> reasonable, and users shouldn't notice the difference.

Right. Great, thanks.

> There might be a case for optionally suppressing nulls in
> array_to_json, and it might work reasonably since unlike SQL arrays
> JSON arrays don't have to be regular (if nested they are arrays of
> arrays, not multi-dimensional single arrays). OTOH I'm not sure if
> it's worth doing just for the sake of orthogonality. If someone
> wants it, then go for it.

Ok. I'll handle updating both of these to remove the overloading
and use default params instead, but I'll only add the 'ignore_null'
option to row_to_json.

Thanks again!

Stephen


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-11 22:18:31
Message-ID: 20140911221831.GH16422@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

All,

* Stephen Frost (sfrost(at)snowman(dot)net) wrote:
> Ok. I'll handle updating both of these to remove the overloading
> and use default params instead, but I'll only add the 'ignore_null'
> option to row_to_json.

Barring objections or any issues I find as I go back through it, this is
what I'm planning to push a bit later on tonight.

Thanks!

Stephen

Attachment Content-Type Size
row_to_json_ignorenull-5.patch text/x-diff 11.0 KB

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: ignore null fields in not relation type composite type based constructors
Date: 2014-09-12 01:32:44
Message-ID: 20140912013244.GK16422@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Stephen Frost (sfrost(at)snowman(dot)net) wrote:
> * Stephen Frost (sfrost(at)snowman(dot)net) wrote:
> > Ok. I'll handle updating both of these to remove the overloading
> > and use default params instead, but I'll only add the 'ignore_null'
> > option to row_to_json.
>
> Barring objections or any issues I find as I go back through it, this is
> what I'm planning to push a bit later on tonight.

Pushed.

Thanks!

Stephen