Hive
  1. Hive
  2. HIVE-2927

Allow escape character in get_json_object

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 0.8.1, 0.9.0
    • Fix Version/s: None
    • Labels:
      None

      Description

      Background:
      get_json_object extracts json objects from a json string based on a specified path.

      Problem:
      The current implementation of get_json_object can't see keys with a '.' in them. Our data contains '.' in the keys, so we have to filter our json keys through a streaming script to replace '.' for '_'.

      Example:
      {{json = {"a":

      {"b": 1}

      , "c.d": 2}}}

      get_json_object(json, "$.a.b") returns: 1
      get_json_object(json, "$.c.d") returns: NULL

      In the present implementation of get_json_object, c.d is not addressable.

      Proposal:
      The desired behavior would be to allow the JSON path to be escape-able, like so:

      get_json_object(json, '$.c\\\.d') would return: 2

        Activity

        Hide
        Vlad Zhidkov added a comment -

        Is anyone planning to work on this feature? Are there any known workarounds? My specific problem has to do with '$' characters in the field names.

        Show
        Vlad Zhidkov added a comment - Is anyone planning to work on this feature? Are there any known workarounds? My specific problem has to do with '$' characters in the field names.
        Ashutosh Chauhan made changes -
        Fix Version/s 0.9.0 [ 12317742 ]
        Affects Version/s 0.9.0 [ 12317742 ]
        Hide
        Ashutosh Chauhan added a comment -

        Unlinking from 0.9

        Show
        Ashutosh Chauhan added a comment - Unlinking from 0.9
        Sean McNamara made changes -
        Fix Version/s 0.9.0 [ 12317742 ]
        Affects Version/s 0.8.1 [ 12319268 ]
        Description *Background:*
        get_json_object extracts json objects from a json string based on a specified path.


        *Problem:*
        The current implementation of get_json_object can't see keys with a '.' in them. Our data contains '.' in the keys, so we have to filter our json keys through a streaming script to replace '.' for '_'.


        *Example:*
        {{json = {"a":{"b": 1}, "c.d": 2}}}

        {{get_json_object(json, "a.b") returns: 1}}
        {{get_json_object(json, "c.d") returns: NULL}}

        In the present implementation of get_json_object, c.d is not addressable.


        *Proposal:*
        The desired behavior would be to allow the JSON path to be escape-able, like so:

        {{get_json_object(json, '$.c\\\.d') would return: 2}}
        *Background:*
        get_json_object extracts json objects from a json string based on a specified path.


        *Problem:*
        The current implementation of get_json_object can't see keys with a '.' in them. Our data contains '.' in the keys, so we have to filter our json keys through a streaming script to replace '.' for '_'.


        *Example:*
        {{json = {"a":{"b": 1}, "c.d": 2}}}

        {{get_json_object(json, "$.a.b") returns: 1}}
        {{get_json_object(json, "$.c.d") returns: NULL}}

        In the present implementation of get_json_object, c.d is not addressable.


        *Proposal:*
        The desired behavior would be to allow the JSON path to be escape-able, like so:

        {{get_json_object(json, '$.c\\\.d') would return: 2}}
        Sean McNamara made changes -
        Component/s Serializers/Deserializers [ 12312585 ]
        Component/s Security [ 12313866 ]
        Hide
        Sean McNamara added a comment -

        Needs code review. thnx!

        Show
        Sean McNamara added a comment - Needs code review. thnx!
        Sean McNamara made changes -
        Attachment HIVE-2927.1.patch.txt [ 12521537 ]
        Hide
        Sean McNamara added a comment -

        Patch adds ability to escape '.' in JSON keys using
        .

        Show
        Sean McNamara added a comment - Patch adds ability to escape '.' in JSON keys using .
        Sean McNamara made changes -
        Description *Background:*
        get_json_object extracts json objects from a json string based on a specified path.


        *Problem:*
        The current implementation of get_json_object can't see keys with a '.' in them. Our data contains '.' in the keys, so we have to filter our json keys through a streaming script to replace '.' for '_'.


        *Example:*
        {{json = {"a":{"b": 1}, "c.d": 2}}}

        {{get_json_object(json, "a.b") returns: 1}}
        {{get_json_object(json, "c.d") returns: NULL}}

        In the present implementation of get_json_object, c.d is not addressable.


        *Proposal:*
        The desired behavior would be to allow the JSON path to be escape-able, like so:

        {{get_json_object(json, '$.c\\\\.d') would return: 2}}
        *Background:*
        get_json_object extracts json objects from a json string based on a specified path.


        *Problem:*
        The current implementation of get_json_object can't see keys with a '.' in them. Our data contains '.' in the keys, so we have to filter our json keys through a streaming script to replace '.' for '_'.


        *Example:*
        {{json = {"a":{"b": 1}, "c.d": 2}}}

        {{get_json_object(json, "a.b") returns: 1}}
        {{get_json_object(json, "c.d") returns: NULL}}

        In the present implementation of get_json_object, c.d is not addressable.


        *Proposal:*
        The desired behavior would be to allow the JSON path to be escape-able, like so:

        {{get_json_object(json, '$.c\\\.d') would return: 2}}
        Sean McNamara made changes -
        Field Original Value New Value
        Fix Version/s 0.9.0 [ 12317742 ]
        Affects Version/s 0.8.1 [ 12319268 ]
        Description *Background:*
        get_json_object extracts json objects from a json string based on a specified path.


        *Problem:*
        The current implementation of get_json_object can't see keys with a '.' in them. Our data contains '.' in the keys, so we have to filter our json keys through a streaming script to replace '.' for '_'.


        *Example:*
        {{json = {"a":{"b": 1}, "c.d": 2}}}

        {{get_json_object(json, "a.b") returns: 1}}
        {{get_json_object(json, "c.d") returns: NULL}}

        In the present implementation of get_json_object, c.d is not addressable.


        *Proposal:*
        The desired behavior would be to allow the JSON path to be escape-able, like so:

        {{get_json_object(json, '$.c\\.d') would return: 2}}
        *Background:*
        get_json_object extracts json objects from a json string based on a specified path.


        *Problem:*
        The current implementation of get_json_object can't see keys with a '.' in them. Our data contains '.' in the keys, so we have to filter our json keys through a streaming script to replace '.' for '_'.


        *Example:*
        {{json = {"a":{"b": 1}, "c.d": 2}}}

        {{get_json_object(json, "a.b") returns: 1}}
        {{get_json_object(json, "c.d") returns: NULL}}

        In the present implementation of get_json_object, c.d is not addressable.


        *Proposal:*
        The desired behavior would be to allow the JSON path to be escape-able, like so:

        {{get_json_object(json, '$.c\\\\.d') would return: 2}}
        Component/s Security [ 12313866 ]
        Component/s Serializers/Deserializers [ 12312585 ]
        Sean McNamara created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Sean McNamara
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development