Skip to content

Commit

Permalink
fix(cubesql): Disallow ematching cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
MazterQyou committed Apr 29, 2024
1 parent bfc0708 commit 4902c6d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/cubejs-backend-native/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion rust/cubesql/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/cubesql/cubesql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ nanoid = "0.3.0"
tokio-util = { version = "0.6.2", features=["compat"] }
comfy-table = "7.1.0"
bitflags = "1.3.2"
egg = {rev = "2f1514c58517e2f38acfe337175f843f156530cf", git = "https://github.com/egraphs-good/egg.git"}
egg = {rev = "7e60716cc757448bd672f2dc28ef9a0d074dce71", git = "https://github.com/egraphs-good/egg.git"}
paste = "1.0.6"
csv = "1.1.6"
tracing = { version = "0.1.40", features = ["async-await"] }
Expand Down
42 changes: 42 additions & 0 deletions rust/cubesql/cubesql/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22817,4 +22817,46 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
displayable(physical_plan.as_ref()).indent()
);
}

#[tokio::test]
async fn test_no_cycle_applier() {
if !Rewriter::sql_push_down_enabled() {
return;
}
init_logger();

let logical_plan = convert_select_to_query_plan(
r#"
SELECT "customer_gender" AS "customer_gender"
FROM (
SELECT "customer_gender" AS "customer_gender"
FROM "KibanaSampleDataEcommerce"
GROUP BY "customer_gender"
ORDER BY "customer_gender" ASC
) AS "KibanaSampleDataEcommerce"
"#
.to_string(),
DatabaseProtocol::PostgreSQL,
)
.await
.as_logical_plan();

assert_eq!(
logical_plan.find_cube_scan().request,
V1LoadRequestQuery {
measures: Some(vec![]),
dimensions: Some(vec!["KibanaSampleDataEcommerce.customer_gender".to_string()]),
segments: Some(vec![]),
time_dimensions: None,
order: Some(vec![vec![
"KibanaSampleDataEcommerce.customer_gender".to_string(),
"asc".to_string(),
]]),
limit: None,
offset: None,
filters: None,
ungrouped: None,
}
)
}
}
4 changes: 4 additions & 0 deletions rust/cubesql/cubesql/src/compile/rewrite/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,4 +1303,8 @@ impl Analysis<LogicalPlanLanguage> for LogicalPlanAnalysis {
}
}
}

fn allow_ematching_cycles(&self) -> bool {
false
}
}

0 comments on commit 4902c6d

Please sign in to comment.