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 <9erthali...@gmail.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.
>
>

Reply via email to