Nadav Har'El created CASSANDRA-21742:
----------------------------------------
Summary: 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
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
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]