cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Lebresne (JIRA)" <j...@apache.org>
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:20:34 GMT

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

Sylvain Lebresne commented on CASSANDRA-8147:
---------------------------------------------

I don't totally agree with all this. It is correct that we currently only allow one index
per CQL column, and so one cannot index both the keys and values of a given map, but that's
not what the test does. The test only has an index on the keys.

Regarding the {{SELECT}}, provided you do have an indexed clause (which that example has),
it's allowed to have other non-indexed clause (it will require {{ALLOW FILTERING}} but it's
used in the example too).  So I'm not sure why this doesn't work, but it should (it's worth
testing on current 2.1 branch though, maybe this has been fixed since 2.1.0).

bq. I agree that querying a key and a value and on map does not make a lot of sense

Out of curiosity, why wouldn't that make sense?

> Secondary indexing of map keys does not work properly when mixing contains and contains_key
> -------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-8147
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-8147
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: 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
(v6.3.4#6332)

Mime
View raw message