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
2 changes: 0 additions & 2 deletions src/repr/src/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ optimizer_feature_flags!({
// See the feature flag of the same name.
enable_projection_pushdown_after_relation_cse: bool,
// See the feature flag of the same name.
enable_let_prefix_extraction: bool,
// See the feature flag of the same name.
enable_less_reduce_in_eqprop: bool,
});

Expand Down
1 change: 0 additions & 1 deletion src/sql/src/plan/statement/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4653,7 +4653,6 @@ pub fn unplan_create_cluster(
enable_reduce_reduction: _,
enable_join_prioritize_arranged,
enable_projection_pushdown_after_relation_cse,
enable_let_prefix_extraction: _,
enable_less_reduce_in_eqprop: _,
} = optimizer_feature_overrides;
// The ones from above that don't occur below are not wired up to cluster features.
Expand Down
1 change: 0 additions & 1 deletion src/sql/src/plan/statement/dml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ impl TryFrom<ExplainPlanOptionExtracted> for ExplainConfig {
enable_join_prioritize_arranged: v.enable_join_prioritize_arranged,
enable_projection_pushdown_after_relation_cse: v
.enable_projection_pushdown_after_relation_cse,
enable_let_prefix_extraction: Default::default(),
enable_less_reduce_in_eqprop: Default::default(),
},
})
Expand Down
7 changes: 0 additions & 7 deletions src/sql/src/session/vars/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1785,12 +1785,6 @@ macro_rules! feature_flags {
}

feature_flags!(
{
name: enable_let_prefix_extraction,
desc: "Enables hoisting of loop-invariant CTE bindindgs",
default: true,
enable_for_item_parsing: false,
},
// Gates for other feature flags
{
name: allow_real_time_recency,
Expand Down Expand Up @@ -2233,7 +2227,6 @@ impl From<&super::SystemVars> for OptimizerFeatures {
enable_join_prioritize_arranged: vars.enable_join_prioritize_arranged(),
enable_projection_pushdown_after_relation_cse: vars
.enable_projection_pushdown_after_relation_cse(),
enable_let_prefix_extraction: vars.enable_let_prefix_extraction(),
enable_less_reduce_in_eqprop: vars.enable_less_reduce_in_eqprop(),
}
}
Expand Down
52 changes: 12 additions & 40 deletions src/transform/src/normalize_lets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,32 +132,6 @@ impl NormalizeLets {

// A final bottom-up traversal to normalize the shape of nested LetRec blocks
relation.try_visit_mut_post(&mut |relation| -> Result<(), RecursionLimitError> {
if !features.enable_let_prefix_extraction {
// Disassemble `LetRec` into a `Let` stack if possible.
// If a `LetRec` remains, return the would-be `Let` bindings to it.
// This is to maintain `LetRec`-freedom for `LetRec`-free expressions.
let mut bindings = let_motion::harvest_non_recursive(relation);
if let MirRelationExpr::LetRec {
ids,
values,
limits,
body: _,
} = relation
{
bindings.extend(ids.drain(..).zip(values.drain(..).zip(limits.drain(..))));
support::replace_bindings_from_map(bindings, ids, values, limits);
} else {
for (id, (value, max_iter)) in bindings.into_iter().rev() {
assert_none!(max_iter);
*relation = MirRelationExpr::Let {
id,
value: Box::new(value),
body: Box::new(relation.take_dangerous()),
};
}
}
}

// Move a non-recursive suffix of bindings from the end of the LetRec
// to the LetRec body.
// This is unsafe when applied to expressions which contain `ArrangeBy`,
Expand Down Expand Up @@ -189,20 +163,18 @@ impl NormalizeLets {
}
}

if features.enable_let_prefix_extraction {
// Extract `Let` prefixes from `LetRec`, to reveal their non-recursive nature.
// This assists with hoisting e.g. arrangements out of `LetRec` blocks, a thing
// we don't promise to do, but it can be helpful to do. This also exposes more
// AST nodes to non-`LetRec` analyses, which don't always have parity with `LetRec`.
let bindings = let_motion::harvest_non_recursive(relation);
for (id, (value, max_iter)) in bindings.into_iter().rev() {
assert_none!(max_iter);
*relation = MirRelationExpr::Let {
id,
value: Box::new(value),
body: Box::new(relation.take_dangerous()),
};
}
// Extract `Let` prefixes from `LetRec`, to reveal their non-recursive nature.
// This assists with hoisting e.g. arrangements out of `LetRec` blocks, a thing
// we don't promise to do, but it can be helpful to do. This also exposes more
// AST nodes to non-`LetRec` analyses, which don't always have parity with `LetRec`.
let bindings = let_motion::harvest_non_recursive(relation);
for (id, (value, max_iter)) in bindings.into_iter().rev() {
assert_none!(max_iter);
*relation = MirRelationExpr::Let {
id,
value: Box::new(value),
body: Box::new(relation.take_dangerous()),
};
}

Ok(())
Expand Down
1 change: 0 additions & 1 deletion src/transform/tests/test_transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ fn apply_transform<T: mz_transform::Transform>(
let mut features = mz_repr::optimize::OptimizerFeatures::default();
// Apply a non-default feature flag to test the right implementation.
features.enable_letrec_fixpoint_analysis = true;
features.enable_let_prefix_extraction = true;
let typecheck_ctx = mz_transform::typecheck::empty_context();
let mut df_meta = DataflowMetainfo::default();
let mut transform_ctx =
Expand Down