Skip to content
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

refactor(cubesql): Move all wrapper replacers params to separate enode #9105

Merged
merged 1 commit into from
Jan 20, 2025
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
55 changes: 22 additions & 33 deletions rust/cubesql/cubesql/src/compile/rewrite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,10 @@ crate::plan_to_language! {
members: Vec<LogicalPlan>,
alias_to_cube: Vec<(String, String)>,
},
WrapperPushdownReplacer {
member: Arc<LogicalPlan>,
WrapperReplacerContext {
alias_to_cube: Vec<(String, String)>,
// This means that result of this replacer would be used as member expression in load query to Cube.
// This flag should be passed from top, by the rule that starts wrapping new logical plan node.
// When `member` is expression this means that result of this replacer should be used as member expression in load query to Cube.
// When `member` is logical plan node this means that logical plan inside allows to push to Cube
// Important caveat: it means that result would be used for push to cube *and only there*.
// So it's more like "must push to Cube" than "can push to Cube"
// This part is important for rewrites like SUM(sumMeasure) => sumMeasure
Expand All @@ -471,23 +470,19 @@ crate::plan_to_language! {
// Used to allow to rewrite columns from them even with push to Cube enabled
grouped_subqueries: Vec<String>,
},
WrapperPushdownReplacer {
member: Arc<LogicalPlan>,
// Only WrapperReplacerContext should be allowed here
// Context be passed from top, by the rule that starts wrapping new logical plan node,
// and should make roundtrip from top to bottom and back.
context: Arc<LogicalPlan>,
},
WrapperPullupReplacer {
member: Arc<LogicalPlan>,
alias_to_cube: Vec<(String, String)>,
// When `member` is expression this means that result of this replacer should be used as member expression in load query to Cube.
// When `member` is logical plan node this means that logical plan inside allows to push to Cube
// This flag should make roundtrip from top to bottom and back.
// Important caveat: it means that result should be used for push to cube *and only there*.
// So it's more like "must push to Cube" than "can push to Cube"
// This part is important for rewrites like SUM(sumMeasure) => sumMeasure
// We can use sumMeasure instead of SUM(sumMeasure) ONLY in with push to Cube
// An vice versa, we can't use SUM(sumMeasure) in grouped query to Cube, so it can be allowed ONLY without push to grouped Cube query
push_to_cube: bool,
in_projection: bool,
cube_members: Vec<LogicalPlan>,
// Known qualifiers of grouped subqueries
// Used to allow to rewrite columns from them even with push to Cube enabled
grouped_subqueries: Vec<String>,
// Only WrapperReplacerContext should be allowed here
// Context be passed from top, by the rule that starts wrapping new logical plan node,
// and should make roundtrip from top to bottom and back.
context: Arc<LogicalPlan>,
},
FlattenPushdownReplacer {
expr: Arc<Expr>,
Expand Down Expand Up @@ -1973,30 +1968,24 @@ fn case_expr_replacer(members: impl Display, alias_to_cube: impl Display) -> Str
format!("(CaseExprReplacer {} {})", members, alias_to_cube)
}

fn wrapper_pushdown_replacer(
members: impl Display,
fn wrapper_replacer_context(
alias_to_cube: impl Display,
push_to_cube: impl Display,
in_projection: impl Display,
cube_members: impl Display,
grouped_subqueries: impl Display,
) -> String {
format!(
"(WrapperPushdownReplacer {members} {alias_to_cube} {push_to_cube} {in_projection} {cube_members} {grouped_subqueries})",
"(WrapperReplacerContext {alias_to_cube} {push_to_cube} {in_projection} {cube_members} {grouped_subqueries})",
)
}

fn wrapper_pullup_replacer(
members: impl Display,
alias_to_cube: impl Display,
push_to_cube: impl Display,
in_projection: impl Display,
cube_members: impl Display,
grouped_subqueries: impl Display,
) -> String {
format!(
"(WrapperPullupReplacer {members} {alias_to_cube} {push_to_cube} {in_projection} {cube_members} {grouped_subqueries})",
)
fn wrapper_pushdown_replacer(members: impl Display, context: impl Display) -> String {
format!("(WrapperPushdownReplacer {members} {context})",)
}

fn wrapper_pullup_replacer(members: impl Display, context: impl Display) -> String {
format!("(WrapperPullupReplacer {members} {context})",)
}

fn flatten_pushdown_replacer(
Expand Down
Loading
Loading