Re: GSoC 2015: Extra Jsonb functionality

From: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: GSoC 2015: Extra Jsonb functionality
Date: 2015-03-19 13:23:10
Message-ID: CA+q6zcXM4VNX0ZKboTuRhFQZJxw8dZak6sb09s5=Y7Bi0ceb3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Synopsis: Althrough Jsonb was introduced in PostgreSQL 9.4, there are
several functions, that still missing. Partially this missing functionality
was implemented in this extension [1] and the corresponding patch [2]. The
purpose of this work is to implement the rest of functions accordingly to
importance.

Benefits: New functionality, than can made the usage of the jsonb more
convenient.

Deliverables: Implementation of the following functions (in the form of an
extension
* jsonb_delete_jsonb - delete key/value pairs based on the other jsonb.
Example of usage:

=# jsonb_delete_jsonb('{"a": 1, "b": {"c": 2, "d": 3}, "f": [4,
5]}'::jsonb, '{"a": 4, "f": [4, 5], "c": 2}'::jsonb);

jsonb_delete_jsonb
---------------------------------------
{"a": 1, "b": {"c": 2, "d": 3}}

* jsonb_slice - extract a subset of an jsonb
Example of usage:

=# jsonb_slice('{"a": 1, "b": {"c": 2}, "d": {"f": 3}}'::jsonb,
ARRAY['b', 'f', 'x']);

jsonb_slice
---------------------------
{"b": {"c": 2}, "f": 3}

* jsonb_to_array - get jsonb keys and values as an array
Example of usage:

=# jsonb_to_array('{"a": 1, "b": {"c": 2}, "d": [3, 4]}'::jsonb);

jsonb_to_array
------------------------------
{a, 1, b, c, 2, d, 3, 4}

* jsonb_keys - get jsonb keys as an array
Example of usage:

=# jsonb_keys('{"a": 1, "b": {"c": 2}}'::jsonb);

jsonb_keys
-----------------
{a, b, c}

* jsonb_vals - get jsonb values as an array
Example of usage:

=# jsonb_vals('{"a": 1, "b": {"c": 2}, "d": [3, 4]}'::jsonb);

jsonb_vals
------------------
{1, 2, 3, 4}

* jsonb_add_to_path - append a new element to jsonb value at the
specific path
Example of usage:

=# jsonb_add_to_path('{"a": 1, "b": {"c": ["d", "f"]}}'::jsonb, {b,
c}::text[], '["g"]'::jsonb);

jsonb_add_to_path
-------------------------------------------
{"a": 1, "b": {"c": ["d", "f", "g"]}}

* jsonb_intersection - extract intersecting key/value pairs
Example of usage:

=# jsonb_intersection('{"a": 1, "b": 2, "d": {"f": 3}, "g": [4,
5]}'::jsonb, '{"b": 2, "c": 3, "f": 3, "g": [4, 5]}'::jsonb);

jsonb_intersection
----------------------------
{"b": 2, "g": [4, 5]}

Schedule: I suppose, this can take 2-3 months for me. First of all I'll
implement the jsonb_delete_jsonb, jsonb_slice, jsonb_to_array, jsonb_keys,
jsonb_vals functions (just because it almost clear how to implement them).
Each function will require tests, and certainly some time will be spent at
the finish on the improvements for extension as a whole.

Unfortunately, this proposal isn't submitted to the GSoC system yet (I'm
planning to do this in the next Tuesday).

[1]: https://github.com/erthalion/jsonbx
[2]: https://commitfest.postgresql.org/4/154/

On 19 March 2015 at 20:16, Dmitry Dolgov <9erthalion6(at)gmail(dot)com> wrote:

> Hi, everyone
>
> I'm Dmitry Dolgov, a phd student at the KemSU, Russia. I would like to
> submit a proposal to the GSoC about additional jsonb functionality, and I
> want to get any feedback and thougths about this.
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2015-03-19 13:35:14 Re: assessing parallel-safety
Previous Message Dmitry Dolgov 2015-03-19 13:16:56 GSoC 2015: Extra Jsonb functionality