cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Lerer (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-8147) Secondary indexing of map keys does not work properly when mixing contains and contains_key
Date Tue, 21 Oct 2014 09:44:34 GMT


Benjamin Lerer commented on CASSANDRA-8147:

{quote}(it's worth testing on current 2.1 branch though, maybe this has been fixed since 2.1.0).{quote}
I tested it on the latest 2.1

{quote}Out of curiosity, why wouldn't that make sense?{quote}
As a map can only have one value associated to a given key, using such a query means that
you want to check that the key exists and that the value is the one you think it should be.
If you select using a contains key only you will be able to have the same information but
you will also know if it is the key which is missing or the value which is not what you expect.
That is why I think that it does not make a lot of sense and that an error message will be
fine for me if I was a user.
Now as a user it is also true that it will also give me a better sense of robustness if the
query was handled properly ;-)   

> Secondary indexing of map keys does not work properly when mixing contains and contains_key
> -------------------------------------------------------------------------------------------
>                 Key: CASSANDRA-8147
>                 URL:
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Benjamin Lerer
>            Assignee: Benjamin Lerer
>            Priority: Minor
> If you have a table with a map column and an index on the map key selecting data using
a contains key and a contains will not return the expected data.
> The problem can be reproduced using the following unit test:
> {code}
>     @Test
>     public void testMapKeyContainsAndValueContains() throws Throwable
>     {
>         createTable("CREATE TABLE %s (account text, id int, categories map<text,text>,
PRIMARY KEY (account, id))");
>         createIndex("CREATE INDEX ON %s(keys(categories))");
>         execute("INSERT INTO %s (account, id , categories) VALUES (?, ?, ?)", "test",
5, map("lmn", "foo"));
>         assertRows(execute("SELECT * FROM %s WHERE account = ? AND id = ? AND categories
CONTAINS KEY ? AND categories CONTAINS ? ALLOW FILTERING", "test", 5, "lmn", "foo"), row("test",
5, map("lmn", "foo")));  
>     }
> {code}

This message was sent by Atlassian JIRA

View raw message