Re: GSoC 2015: Extra Jsonb functionality - Mailing list pgsql-hackers

From Dmitry Dolgov
Subject Re: GSoC 2015: Extra Jsonb functionality
Date
Msg-id CA+q6zcXM4VNX0ZKboTuRhFQZJxw8dZak6sb09s5=Y7Bi0ceb3A@mail.gmail.com
Whole thread Raw
In response to GSoC 2015: Extra Jsonb functionality  (Dmitry Dolgov <9erthalion6@gmail.com>)
Responses Re: GSoC 2015: Extra Jsonb functionality  (Thom Brown <thom@linux.com>)
Re: GSoC 2015: Extra Jsonb functionality  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List 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).


On 19 March 2015 at 20:16, Dmitry Dolgov <9erthalion6@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.


pgsql-hackers by date:

Previous
From: Dmitry Dolgov
Date:
Subject: GSoC 2015: Extra Jsonb functionality
Next
From: Amit Kapila
Date:
Subject: Re: assessing parallel-safety