Re: proposal: ignore null fields in not relation type composite type based constructors - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: proposal: ignore null fields in not relation type composite type based constructors
Date
Msg-id CAFj8pRCizZwv2yFMCQs6bVGofaELPY7tQx4sZs_WT1FVwj+Q3A@mail.gmail.com
Whole thread Raw
In response to proposal: ignore null fields in not relation type composite type based constructors  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: Re: proposal: ignore null fields in not relation type composite type based constructors  (Jeevan Chalke <jeevan.chalke@enterprisedb.com>)
List 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.stehule@gmail.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

pgsql-hackers by date:

Previous
From: Kevin Grittner
Date:
Subject: Re: delta relations in AFTER triggers
Next
From: Heikki Linnakangas
Date:
Subject: Re: better atomics - v0.5