mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-01 13:45:53 +00:00
Currently we support queries like: ```cql SELECT * FROM ks.tab WHERE p IN (1, 2, null, 4); ``` Nothing can be equal to null so this is equivalent to: ```cql SELECT * FROM ks.tab WHERE p IN (1, 2, 4); ``` Cassandra doesn't support it at all. ```cql > SELECT * FROM ks.tab WHERE p IN (1, 2, null, 4) Error: DbError(Invalid, "Invalid null value in condition for column p") > SELECT * FROM ks.tab WHERE p IN (1, 2, ?, 4) # ? is NULL Error: DbError(Invalid, "Invalid null value in condition for column p") > SELECT * FROM ks.tab WHERE p IN ? # ? is (1, 2, null, 4) Error: DbError(Invalid, "Invalid null value in condition for column p") ``` It makes little sense to send a null inside list of IN values and supporting it is a bit cumbersome. Supporting it causes trouble because internally the values are represented as a list, not a tuple, and lists can't contain nulls. Because of that code requires exceptions because in this single case there can be a null inside of a collection. This PR starts treating a llist of IN values the same as any other list and as result nulls are forbidden inside them. In case of a null the message is the same as any other collection: ``` null is not supported inside collections ``` I'm not entirely happy about it - someone could be confused if they received this message after a query that didn't involve any collections. The problem with making a prettier error message is that once again we would have to give `evaluate` additional information that it's now evaluating a list of IN values. And we would end up back with `evaluate_IN_list` I think we could consider adding some kind of generic context to evaluate. The context would contain the whole expression and a mark on the part that we are currently evaluating. Then in case of error we could use this context and use it to create more helpful error messages, e.g. point to the part of the expression where a problem occured. But that's outside of the scope of this PR. Fixes #10579 Closes #10620 * github.com:scylladb/scylla: cql: Add test for null in IN list cql: Forbid null in lists of IN values