[
https://issues.apache.org/jira/browse/CASSANDRA-21740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18130879#comment-18130879
]
Stefan Miklosovic edited comment on CASSANDRA-21740 at 11/3/26, 1:01 PM:
-------------------------------------------------------------------------
+1, worth to say that it is still an issue for 4.0 and 5.0, [~dipach] you can
either prepare a patch for 4.0, 4.1 and 5.0 or we go without only for 6.0 and
beyond. It should be trivial to do that.
Preparing a query with a slice restriction ({{{}<{}}}, {{{}<={}}}, {{{}>{}}},
{{{}>={}}}) on a partition key column returns metadata that lists the slice
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:java}
CREATE TABLE ks.t (k int, c int, v int, PRIMARY KEY (k, c));
-- prepare:
SELECT * FROM ks.t WHERE k > ? ALLOW FILTERING; -- pk_indexes =
[0]
SELECT * FROM ks.t WHERE k > ? AND k < ? ALLOW FILTERING; -- pk_indexes =
[1]
CREATE TABLE ks.t2 (k1 int, k2 int, v int, PRIMARY KEY ((k1, k2)));
SELECT * FROM ks.t2 WHERE k1 = ? AND k2 > ? ALLOW FILTERING; -- pk_indexes =
[0, 1]
-- for comparison:
SELECT * FROM ks.t WHERE token(k) > ?; -- no pk_indexes
SELECT * FROM ks.t WHERE k = ?; -- pk_indexes =
[0]
{code}
was (Author: smiklosovic):
+1, worth to say that it is still an issue for 4.0 and 5.0, [~dipach] you can
either prepare a patch for 4.0, 4.1 and 5.0 or we go without only for 6.0 and
beyond. It should be trivial to do that.
Preparing a query with a slice restriction ({{{}<{}}}, {{{}<={}}}, {{{}>{}}},
{{{}>={}}}) on a partition key column returns metadata that lists the slice
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:java}
{code:sql}
CREATE TABLE ks.t (k int, c int, v int, PRIMARY KEY (k, c));
-- prepare:
SELECT * FROM ks.t WHERE k > ? ALLOW FILTERING; -- pk_indexes =
[0]
SELECT * FROM ks.t WHERE k > ? AND k < ? ALLOW FILTERING; -- pk_indexes =
[1]
CREATE TABLE ks.t2 (k1 int, k2 int, v int, PRIMARY KEY ((k1, k2)));
SELECT * FROM ks.t2 WHERE k1 = ? AND k2 > ? ALLOW FILTERING; -- pk_indexes =
[0, 1]
-- for comparison:
SELECT * FROM ks.t WHERE token(k) > ?; -- no pk_indexes
SELECT * FROM ks.t WHERE k = ?; -- pk_indexes =
[0]
{code}
> 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
> Components: Feature/Prepared Statements
> Reporter: Nadav Har'El
> Assignee: Dipankar Achinta
> Priority: Normal
> Fix For: 4.0.x, 4.1.x, 5.0.x, 6.x, 7.x
>
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> 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
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]