Skip to content

Commit 8d1080b

Browse files
committed
fix(cubesql): Drop ordering from CubeScan during CrossJoin rewrite
CROSS JOIN does not guarantee same ordering as inputs
1 parent bed4289 commit 8d1080b

File tree

2 files changed

+5
-44
lines changed

2 files changed

+5
-44
lines changed

rust/cubesql/cubesql/src/compile/rewrite/rules/members.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,19 +2567,13 @@ impl MemberRules {
25672567
left_alias_to_cube_var: &'static str,
25682568
right_alias_to_cube_var: &'static str,
25692569
joined_alias_to_cube_var: &'static str,
2570-
left_order_var: &'static str,
2571-
right_order_var: &'static str,
2572-
new_order_var: &'static str,
25732570
left_ungrouped_var: &'static str,
25742571
right_ungrouped_var: &'static str,
25752572
new_ungrouped_var: &'static str,
25762573
) -> impl Fn(&mut CubeEGraph, &mut Subst) -> bool {
25772574
let left_alias_to_cube_var = var!(left_alias_to_cube_var);
25782575
let right_alias_to_cube_var = var!(right_alias_to_cube_var);
25792576
let joined_alias_to_cube_var = var!(joined_alias_to_cube_var);
2580-
let left_order_var = var!(left_order_var);
2581-
let right_order_var = var!(right_order_var);
2582-
let new_order_var = var!(new_order_var);
25832577
let left_ungrouped_var = var!(left_ungrouped_var);
25842578
let right_ungrouped_var = var!(right_ungrouped_var);
25852579
let new_ungrouped_var = var!(new_ungrouped_var);
@@ -2601,16 +2595,6 @@ impl MemberRules {
26012595
for right_alias_to_cube in
26022596
var_iter!(egraph[subst[right_alias_to_cube_var]], CubeScanAliasToCube).cloned()
26032597
{
2604-
let is_left_order_empty =
2605-
Some(true) == egraph[subst[left_order_var]].data.is_empty_list;
2606-
2607-
let is_right_order_empty =
2608-
Some(true) == egraph[subst[right_order_var]].data.is_empty_list;
2609-
2610-
if !is_left_order_empty && !is_right_order_empty {
2611-
continue;
2612-
}
2613-
26142598
subst.insert(
26152599
joined_alias_to_cube_var,
26162600
egraph.add(LogicalPlanLanguage::CubeScanAliasToCube(
@@ -2623,14 +2607,6 @@ impl MemberRules {
26232607
)),
26242608
);
26252609

2626-
let orders = if is_left_order_empty {
2627-
subst[right_order_var]
2628-
} else {
2629-
subst[left_order_var]
2630-
};
2631-
2632-
subst.insert(new_order_var, orders);
2633-
26342610
let joined_ungrouped = egraph.add(LogicalPlanLanguage::CubeScanUngrouped(
26352611
CubeScanUngrouped(left_ungrouped && right_ungrouped),
26362612
));
@@ -2708,7 +2684,7 @@ impl MemberRules {
27082684
"?joined_alias_to_cube",
27092685
cube_scan_members(left_members, right_members),
27102686
cube_scan_filters("?left_filters", "?right_filters"),
2711-
"?new_order",
2687+
cube_scan_order_empty_tail(),
27122688
"CubeScanLimit:None",
27132689
"CubeScanOffset:None",
27142690
"CubeScanSplit:false",
@@ -2720,9 +2696,6 @@ impl MemberRules {
27202696
"?left_alias_to_cube",
27212697
"?right_alias_to_cube",
27222698
"?joined_alias_to_cube",
2723-
"?left_order",
2724-
"?right_order",
2725-
"?new_order",
27262699
"?left_ungrouped",
27272700
"?right_ungrouped",
27282701
"?new_ungrouped",

rust/cubesql/cubesql/src/compile/test/test_cube_join.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,7 @@ async fn test_join_two_subqueries_with_filter_order_limit() {
246246
measures: Some(vec!["KibanaSampleDataEcommerce.count".to_string(),]),
247247
dimensions: Some(vec!["Logs.read".to_string(),]),
248248
segments: Some(vec![]),
249-
order: Some(vec![vec![
250-
"KibanaSampleDataEcommerce.customer_gender".to_string(),
251-
"asc".to_string(),
252-
]]),
249+
order: Some(vec![]),
253250
filters: Some(vec![
254251
V1LoadRequestQueryFilterItem {
255252
member: Some("KibanaSampleDataEcommerce.customer_gender".to_string()),
@@ -301,10 +298,7 @@ async fn test_join_three_subqueries_with_filter_order_limit_and_split() {
301298
granularity: Some("month".to_owned()),
302299
date_range: None
303300
}]),
304-
order: Some(vec![vec![
305-
"KibanaSampleDataEcommerce.customer_gender".to_string(),
306-
"asc".to_string(),
307-
]]),
301+
order: Some(vec![]),
308302
filters: Some(vec![
309303
V1LoadRequestQueryFilterItem {
310304
member: Some("KibanaSampleDataEcommerce.customer_gender".to_string()),
@@ -350,10 +344,7 @@ async fn test_join_subquery_and_table_with_filter_order_limit() {
350344
measures: Some(vec!["KibanaSampleDataEcommerce.count".to_string(),]),
351345
dimensions: Some(vec!["Logs.read".to_string(),]),
352346
segments: Some(vec![]),
353-
order: Some(vec![vec![
354-
"KibanaSampleDataEcommerce.customer_gender".to_string(),
355-
"asc".to_string(),
356-
]]),
347+
order: Some(vec![]),
357348
filters: Some(vec![
358349
V1LoadRequestQueryFilterItem {
359350
member: Some("KibanaSampleDataEcommerce.customer_gender".to_string()),
@@ -405,10 +396,7 @@ async fn test_join_two_subqueries_and_table_with_filter_order_limit_and_split()
405396
granularity: Some("month".to_owned()),
406397
date_range: None
407398
}]),
408-
order: Some(vec![vec![
409-
"KibanaSampleDataEcommerce.customer_gender".to_string(),
410-
"asc".to_string(),
411-
]]),
399+
order: Some(vec![]),
412400
filters: Some(vec![
413401
V1LoadRequestQueryFilterItem {
414402
member: Some("KibanaSampleDataEcommerce.customer_gender".to_string()),

0 commit comments

Comments
 (0)