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

Window function fusion #29276

Merged
merged 4 commits into from
Aug 29, 2024
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
3 changes: 3 additions & 0 deletions src/adapter/src/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ impl From<&OptimizerConfig> for mz_sql::plan::HirToMirConfig {
enable_new_outer_join_lowering: config.features.enable_new_outer_join_lowering,
enable_variadic_left_join_lowering: config.features.enable_variadic_left_join_lowering,
enable_outer_join_null_filter: config.features.enable_outer_join_null_filter,
enable_value_window_function_fusion: config
.features
.enable_value_window_function_fusion,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/compute-types/src/plan/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,8 @@ pub fn reduction_type(func: &AggregateFunc) -> ReductionType {
| AggregateFunc::LagLead { .. }
| AggregateFunc::FirstValue { .. }
| AggregateFunc::LastValue { .. }
| AggregateFunc::WindowAggregate { .. } => ReductionType::Basic,
| AggregateFunc::WindowAggregate { .. }
| AggregateFunc::FusedValueWindowFunc { .. } => ReductionType::Basic,
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/compute/src/render/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,8 @@ where
let key_len = datums_local.len();
datums_local.push(
// Note that this is not necessarily a window aggregation, in which case
// `eval_fast_window_agg` delegates to the normal `eval`.
func.eval_fast_window_agg::<_, window_agg_helpers::OneByOneAggrImpls>(
// `eval_with_fast_window_agg` delegates to the normal `eval`.
func.eval_with_fast_window_agg::<_, window_agg_helpers::OneByOneAggrImpls>(
iter,
&temp_storage,
),
Expand Down Expand Up @@ -845,7 +845,7 @@ where
let mut datums_local = datums2.borrow();
datums_local.extend(datum_iter);
datums_local.push(
func2.eval_fast_window_agg::<_, window_agg_helpers::OneByOneAggrImpls>(
func2.eval_with_fast_window_agg::<_, window_agg_helpers::OneByOneAggrImpls>(
iter,
&temp_storage,
),
Expand Down Expand Up @@ -2414,7 +2414,8 @@ mod monoids {
| AggregateFunc::LagLead { .. }
| AggregateFunc::FirstValue { .. }
| AggregateFunc::LastValue { .. }
| AggregateFunc::WindowAggregate { .. } => None,
| AggregateFunc::WindowAggregate { .. }
| AggregateFunc::FusedValueWindowFunc { .. } => None,
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/expr/src/relation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ message ProtoAggregateFunc {
mz_expr.relation.ProtoWindowFrame window_frame = 3;
}

message ProtoFusedValueWindowFunc {
repeated ProtoAggregateFunc funcs = 1;
ProtoColumnOrders order_by = 2;
}

message ProtoMapAgg {
ProtoColumnOrders order_by = 1;
mz_repr.relation_and_scalar.ProtoScalarType value_type = 2;
Expand Down Expand Up @@ -136,6 +141,7 @@ message ProtoAggregateFunc {
ProtoFramedWindowFunc first_value = 41;
ProtoFramedWindowFunc last_value = 42;
ProtoWindowAggregate window_aggregate = 55;
ProtoFusedValueWindowFunc fused_value_window_func = 57;
google.protobuf.Empty max_uint16 = 43;
google.protobuf.Empty max_uint32 = 44;
google.protobuf.Empty max_uint64 = 45;
Expand Down
Loading
Loading