cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tyler Hobbs (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-9190) Map keys aren't properly serialized as strings in SELECT JSON queries
Date Wed, 13 May 2015 16:51:00 GMT

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

Tyler Hobbs commented on CASSANDRA-9190:
----------------------------------------

bq. So if it's just a string literal, is decodeJson a no-op?

No, it's not a no-op.  It will attempt to decode it as a normal JSON string.  For example,
if you've got a {{map<frozen<set<int>>, boolean>}} column and you try to
pass a string literal "abc" for a map key, you'll get an error like the following:

{noformat}
Error decoding JSON value for column1: Error decoding JSON string: Unexpected character ('a'
(code 97)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
{noformat}

I could improve the error message somewhat if you'd like, but it should be a pretty rare case.

> Map keys aren't properly serialized as strings in SELECT JSON queries
> ---------------------------------------------------------------------
>
>                 Key: CASSANDRA-9190
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-9190
>             Project: Cassandra
>          Issue Type: Bug
>          Components: API
>            Reporter: Gianluca Righetto
>            Assignee: Tyler Hobbs
>             Fix For: 2.2 beta 1
>
>         Attachments: 9190-trunk.txt
>
>
> When I run a SELECT JSON query on a table that contains a column of type map, the JSON
output doesn’t wrap the map keys with quotes, thus creating a non-standard JSON representation,
which doesn’t play along with JSON parsers very well. 
> Here’s an example where the map keys are actually a set:
> {code}
> create table table1 (id int primary key, mymap map<frozen<set<int>>,int>);
> insert into table1 (id,mymap) values (1, {{1,2,3,4}:1});
> select json id,mymap from table1;
> {code}
> The output is:
> {noformat}
> {"id": 1, "mymap": {[1, 2, 3, 4]: 1}}
> {noformat}
> But what I expected was that the map key, in this case the entire integer set, would
be wrapped with quotes.
> The same thing happens when the key is a primitive, such as int, or when it’s another
type of collection.
> I tried this with the latest version of the Cassandra codebase from the repository’s
trunk (1f65a12c33).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message