[ 
https://issues.apache.org/jira/browse/CASSANDRA-21742?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hugo Pereira reassigned CASSANDRA-21742:
----------------------------------------

    Assignee: Hugo Pereira

> CONTAINS KEY restriction on a frozen map clustering column with descending 
> order is rejected: "Cannot use CONTAINS KEY on non-map column"
> -----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-21742
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21742
>             Project: Apache Cassandra
>          Issue Type: Bug
>            Reporter: Nadav Har'El
>            Assignee: Hugo Pereira
>            Priority: Normal
>
> A frozen map can be a clustering column, and that column can have descending 
> clustering order. Filtering such a column with CONTAINS KEY is rejected, 
> although the column is a map:
> {code:sql}
> CREATE TABLE ks.t (p int, c frozen<map<int, int>>, PRIMARY KEY (p, c)) WITH 
> CLUSTERING ORDER BY (c DESC);
> INSERT INTO ks.t (p, c) VALUES (1, {1: 10, 2: 20});
> SELECT c FROM ks.t WHERE p = 1 AND c CONTAINS KEY 1 ALLOW FILTERING;
> {code}
> fails with:
> {noformat}
> InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot 
> use CONTAINS KEY on non-map column c"
> {noformat}
> With the default ascending order (no CLUSTERING ORDER BY), the same query 
> works and returns the row.
> The cause seems to be this check in Operator.java:
> {code:java}
> checkFalse(appliesToMapKeys() && !(columnType instanceof MapType), "Cannot 
> use %s on non-map column %s", this, firstColumn.name);
> {code}
> For a column with descending order, the column's type is a ReversedType 
> wrapping the MapType, so the instanceof check fails. CASSANDRA-19950 fixed 
> the same kind of problem (a ReversedType clustering column bypassing 
> "instanceof" type checks) in Relation#toRestriction(), but not this check.
> Reproduced on Cassandra 5.0.9 and 6.0-alpha2.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to