You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2023/01/11 11:33:00 UTC

[jira] [Commented] (IMPALA-11778) Printing maps may produce invalid json

    [ https://issues.apache.org/jira/browse/IMPALA-11778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17672324#comment-17672324 ] 

ASF subversion and git services commented on IMPALA-11778:
----------------------------------------------------------

Commit 53ce60457b9d24fa4a7518a37d8bb9f1791d5825 in impala's branch refs/heads/master from Daniel Becker
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=53ce60457 ]

IMPALA-11778: Printing maps may produce invalid json

Impala allows non-string types, for example numbers, to be keys in maps.
We print maps as json objects, but json objects only allow string keys.
If the Impala map has for example an INT key, the printed json is
invalid.

For example, in Impala the following two maps are not the same:
{1: "a", 2: "b"}
{"1": "a", "2": "b"}

The first map has INT keys, the second has STRING keys. Only the second
one is valid json.

Hive has the same behaviour as Impala, i.e. it produces invalid json if
the map keys have a non-string type.

This change introduces the STRINGIFY_MAP_KEYS query option that, when
set to true, converts non-string keys to strings. The default value of
the new query option is false because
  - conversion to string causes loss of information and
  - setting it to true would be a breaking change.

Testing:
  - Added tests in nested-map-in-select-list.test and map_null_keys.test
    that check the behaviour when STRINGIFY_MAP_KEYS is set to true.

Change-Id: I1820036a1c614c34ae5d70ac4fe79a992c9bce3a
Reviewed-on: http://gerrit.cloudera.org:8080/19364
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


> Printing maps may produce invalid json
> --------------------------------------
>
>                 Key: IMPALA-11778
>                 URL: https://issues.apache.org/jira/browse/IMPALA-11778
>             Project: IMPALA
>          Issue Type: Improvement
>          Components: Backend
>            Reporter: Daniel Becker
>            Assignee: Daniel Becker
>            Priority: Major
>
> Impala allows non-string types, for example numbers, to be keys in maps. We print maps as json objects, but json objects only allow string keys. If the Impala map has for example an INT key, the printed json is invalid.
> For example, in Impala the following two maps are not the same:
> {code:java}
> {1: "a", 2: "b"}{code}
> {code:java}
> {"1": "a", "2": "b"}{code}
> The first map has INT keys, the second has STRING keys. Only the second one is valid json.
> Hive has the same issue.
> Converting all keys to strings is not good because that causes loss of information. On the other hand sometimes we may need valid json, so we could introduce a query option that, when set to true, would convert non-string keys to strings.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org