-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[YCQL] Unable to do explicit ORDER BY sort on clustered columns of index #1591
Comments
This is a bug in YugaByte semantic analysis.
Implementation.
|
Summary: This diff fixed ORDER BY processing. - Analyzing ORDER BY clause should come AFTER instead of BEFORE choosing which INDEX to be used in SCANing. - When an index is chosen, the current code create a duplicate SELECT and run analysis on that duplicate select. After the statement is duplicated, ORDER_BY clause is removed from the user-select. That way, we analyze the clause against ONLY chosen index instead of the table primary key. Test Plan: Add test function "testOrderBy()" to yb-cql::TestIndex suite. Reviewers: mihnea Reviewed By: mihnea Subscribers: yql Differential Revision: https://phabricator.dev.yugabyte.com/D6808
This has been fixed by commit 592fcfa Instead of making copies of column_list (schema) for the indexes as suggested in my previous comment, the existing code made one new copy for the entire SELECT statement, replace the target-table with its chosen table_index, and rerun analysis on the entire SELECT against the chosen table_index. I decided to keep this design of copying the entire SELECT statement in this bug fix as changing the current design would be beyond the scope of this bug fix. To fix the issue, the analysis for ORDER BY clause is now done after the aforementioned copy of original SELECT statement is created and being analyzed. As a result, the error-check is run against the index schema instead of the schema of the target-table. |
When creating a keyspace with the following schema
Queries that use the secondary index and provide an order by will fail with the error:
Leaving the order clause out succeeds
The text was updated successfully, but these errors were encountered: