Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions rust/cubestore/cubestore-sql-tests/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2868,23 +2868,27 @@ async fn physical_plan_flags(service: Box<dyn SqlClient>) {
// (query, is_optimal)
let cases = vec![
("SELECT SUM(hits) FROM s.Data", true),
("SELECT SUM(hits) FROM s.Data WHERE url = 'test'", true),
("SELECT SUM(hits) FROM s.Data WHERE url = 'test' AND day > 'test'", true),
("SELECT SUM(hits) FROM s.Data WHERE url = 'test'", false),
("SELECT SUM(hits) FROM s.Data WHERE url = 'test' AND day > 'test'", false),
("SELECT SUM(hits) FROM s.Data WHERE day = 'test'", false),
("SELECT SUM(hits) FROM s.Data WHERE url = 'test' AND day = 'test'", true),
("SELECT SUM(hits) FROM s.Data WHERE url = 'test' AND day = 'test'", false),
("SELECT SUM(hits) FROM s.Data WHERE url = 'test' AND category = 'test'", false),
("SELECT SUM(hits) FROM s.Data WHERE url = 'test' OR url = 'test_2'", true),
("SELECT SUM(hits) FROM s.Data WHERE url = 'test' OR url = 'test_2'", false),
("SELECT SUM(hits) FROM s.Data WHERE url = 'test' OR category = 'test'", false),
("SELECT SUM(hits) FROM s.Data WHERE (url = 'test' AND day = 'test') OR (url = 'test' AND category = 'test')", false),
("SELECT SUM(hits) FROM s.Data WHERE (url = 'test' AND day = 'test') OR (url = 'test_1' OR url = 'test_2')", true),
("SELECT SUM(hits) FROM s.Data WHERE (url = 'test' AND day = 'test') OR (url = 'test_1' OR url = 'test_2')", false),
("SELECT SUM(hits) FROM s.Data WHERE (url = 'test' AND day = 'test') OR (url = 'test_1' OR day = 'test_2')", false),
("SELECT SUM(hits) FROM s.Data WHERE (url = 'test' AND day = 'test') OR (url = 'test_1' OR day > 'test_2')", true),
("SELECT SUM(hits) FROM s.Data WHERE (url = 'test' AND day = 'test') OR (url = 'test_1' OR day > 'test_2')", false),
("SELECT SUM(hits) FROM s.Data WHERE (url = 'test' AND day = 'test' AND category = 'test')", true),
("SELECT SUM(hits) FROM s.Data WHERE (url = 'test' AND day = 'test' AND category = 'test') OR (url = 'test_2' AND day = 'test_2' AND category = 'test_2')", true),
("SELECT SUM(hits) FROM s.Data WHERE (url = 'test' AND day = 'test' AND category = 'test') OR (url = 'test_2' AND day = 'test_2' AND category > 'test_2')", false),
("SELECT SUM(hits) FROM s.Data WHERE url IN ('test_1', 'test_2')", false),
("SELECT SUM(hits) FROM s.Data WHERE url IS NOT NULL", false),
("SELECT SUM(hits), url FROM s.Data GROUP BY url", true),
("SELECT SUM(hits), url, day FROM s.Data GROUP BY url, day", true),
("SELECT SUM(hits), day FROM s.Data GROUP BY day", false),
("SELECT SUM(hits), day, category FROM s.Data GROUP BY day, category", false),
("SELECT SUM(hits), day, category FROM s.Data GROUP BY day, category", false)
];

for (query, expected_optimal) in cases {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ impl PhysicalPlanFlags {

if let Some(input_exec_any) = maybe_input_exec {
if let Some(cte) = input_exec_any.downcast_ref::<CubeTableExec>() {
let index_columns = cte.index_snapshot.index.row.columns();
let sort_key_size = cte.index_snapshot.index.row.sort_key_size() as usize;
let index_columns =
cte.index_snapshot.index.row.columns()[..sort_key_size].to_vec();
flags.predicate_sorted = Some(check_predicate_order(
predicate_column_groups,
index_columns,
&index_columns,
));
}
}
Expand Down Expand Up @@ -127,13 +129,13 @@ fn check_predicate_order(
for index_name in &index_column_names {
if eq_column_names.contains(index_name) {
checked_length += 1;
} else {
if eq_column_names.len() > checked_length {
return false;
}
continue 'group_loop;
}
}

if index_column_names.len() > checked_length {
return false;
}
continue 'group_loop;
}

true
Expand Down
Loading