mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-24 10:30:38 +00:00
In queries like: ```cql SELECT * FROM t WHERE p = 0 AND c1 = 0 ORDER BY (c1 ASC, c2 ASC) ``` we can skip the requirement to specify ordering for `c1` column. The `c1` column is restricted by an `EQ` restriction, so it can have at most one value anyway, there is no need to sort. This commit makes it possible to write just: ```cql SELECT * FROM t WHERE p = 0 AND c1 = 0 ORDER BY (c2 ASC) ``` I reorganized the ordering code, I feel that it's now clearer and easier to understand. It's possible to only introduce a small change to the existing code, but I feel like it becomes a bit too messy. I tried it out on the [`orderby_disorder_small`](https://github.com/cvybhu/scylla/commits/orderby_disorder_small) branch. The diff is a bit messy because I moved all ordering functions to one place, it's better to read [select_statement.cc](https://github.com/cvybhu/scylla/blob/orderby_disorder/cql3/statements/select_statement.cc#L1495-L1658) lines 1495-1658 directly. In the new code it would also be trivial to allow specifying columns in any order, we would just have to sort them. For now I commented out the code needed to do that, because the point of this PR was to fix #2247. Allowing this would require some more work changing the existing tests. Fixes: #2247 Closes #9518 * github.com:scylladb/scylla: cql-pytest: Enable test for skipping eq restricted columns in order by cql3: Allow to skip EQ restricted columns in ORDER BY cql3: Add has_eq_restriction_on_column function cql3: Reorganize orderings code