Nadav Har'El created CASSANDRA-21740:
----------------------------------------
Summary: Prepared statement metadata reports a bind marker in a
NOT IN restriction on the partition key as a partition key bind index
Key: CASSANDRA-21740
URL: https://issues.apache.org/jira/browse/CASSANDRA-21740
Project: Apache Cassandra
Issue Type: Bug
Reporter: Nadav Har'El
In Cassandra 6.0-alpha2, preparing a query with a {{NOT IN}} restriction on the
partition key returns metadata that lists the {{NOT IN}} bind marker among the
partition key bind indexes (the "pk_indexes" of the PREPARED result), as if it
were a value of the partition key:
{code:sql}
CREATE TABLE ks.t (k int, i int, j int, PRIMARY KEY (k, i, j));
-- prepare:
SELECT * FROM ks.t WHERE k NOT IN (?) ALLOW FILTERING; -- pk_indexes = [0]
SELECT * FROM ks.t WHERE k NOT IN (?, ?) ALLOW FILTERING; -- pk_indexes = [1]
-- for comparison:
SELECT * FROM ks.t WHERE k NOT IN ? ALLOW FILTERING; -- no pk_indexes
SELECT * FROM ks.t WHERE k = ?; -- pk_indexes = [0]
{code}
A value in {{NOT IN}} is a partition key that the query excludes, so it cannot
be used to route the request. With this metadata, token-aware drivers send the
request to the replicas of the excluded key. Drivers may also refuse to execute
the request; for example, the Python driver fails to bind {{UNSET_VALUE}} to
the marker with "ValueError: Cannot bind UNSET_VALUE as a part of the routing
key 'k'". Because of this, the new {{NOT IN}} checks in
{{SelectSingleColumnRelationTest.testWithUnsetValues}} ({{k NOT IN(?)}} and {{k
NOT IN(?,?)}} with {{unset()}}) cannot be run through a driver. CQLTester
doesn't use a driver, so the Java test doesn't notice.
{{NOT IN}} on the partition key was added in CASSANDRA-18584, so this affects
only Cassandra 6. Tested on 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]