Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[YCQL] #3281 Fixed the Issue in Upgrade for SELECT from Indexed Table
Summary: After upgrade server of 2.0 and later versions did not process the existing pre-2.0.5 indexes in the database correctly. - INDEXes that were created before 2.0 releases does not contain column_names. - Newer server uses column names to determine if an expression is covered by the index. The fix - For existing INDEXes, we continue to use column IDs when checking for covering. - Also, when checking for covering, to be safe, the predicate `column_name.empty()` is used. The function "string::find(str, substr)" will return TRUE if "substr" is empty. Test Plan: Test manually. ``` CREATE TABLE test.bbb ( k int PRIMARY KEY, time int, height bigint ) WITH default_time_to_live = 0 AND transactions = {'enabled': 'false'}; CREATE INDEX bbb_height ON test.bbb (height, k) WITH CLUSTERING ORDER BY (k ASC) AND transactions = {'enabled': 'false', 'consistency_level': 'user_enforced'}; cqlsh:test> EXPLAIN SELECT * FROM bbb WHERE height = 1; QUERY PLAN ---------------------------------------------- Index Scan using test.bbb_height on test.bbb Key Conditions: (height = 1) cqlsh:test> describe bbb1; CREATE TABLE test.bbb1 ( k int PRIMARY KEY, time int, height bigint ) WITH default_time_to_live = 0 AND transactions = {'enabled': 'false'}; CREATE INDEX bbb_height1 ON test.bbb1 (height, k) INCLUDE (time) WITH CLUSTERING ORDER BY (k ASC) AND transactions = {'enabled': 'false', 'consistency_level': 'user_enforced'}; cqlsh:test> EXPLAIN SELECT * FROM bbb1 WHERE height = 1; QUERY PLAN ----------------------------------------------------- Index Only Scan using test.bbb_height1 on test.bbb1 Key Conditions: (height = 1) cqlsh:test> describe bbb2; CREATE TABLE test.bbb2 ( k int PRIMARY KEY, time int, height bigint ) WITH default_time_to_live = 0 AND transactions = {'enabled': 'true'}; CREATE INDEX bbb_height2 ON test.bbb2 (height, k) WITH CLUSTERING ORDER BY (k ASC) AND transactions = {'enabled': 'true'}; cqlsh:test> EXPLAIN SELECT * FROM bbb2 WHERE height = 1; QUERY PLAN ------------------------------------------------ Index Scan using test.bbb_height2 on test.bbb2 Key Conditions: (height = 1) cqlsh:test> describe bbb3; CREATE TABLE test.bbb3 ( k int PRIMARY KEY, time int, height bigint ) WITH default_time_to_live = 0 AND transactions = {'enabled': 'true'}; CREATE INDEX bbb_height3 ON test.bbb3 (height, k) INCLUDE (time) WITH CLUSTERING ORDER BY (k ASC) AND transactions = {'enabled': 'true'}; cqlsh:test> EXPLAIN SELECT * FROM bbb3 WHERE height = 1; QUERY PLAN ----------------------------------------------------- Index Only Scan using test.bbb_height3 on test.bbb3 Key Conditions: (height = 1) ``` Reviewers: amitanand, mihnea Reviewed By: mihnea Subscribers: yql Differential Revision: https://phabricator.dev.yugabyte.com/D7768
- Loading branch information