diff --git a/src/adapter/src/optimize.rs b/src/adapter/src/optimize.rs index dcbab3afcca3f..9cbb270289a2a 100644 --- a/src/adapter/src/optimize.rs +++ b/src/adapter/src/optimize.rs @@ -251,10 +251,6 @@ impl From<&OptimizerConfig> for mz_sql::plan::HirToMirConfig { Self { 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_value_window_function_fusion: config - .features - .enable_value_window_function_fusion, - enable_window_aggregation_fusion: config.features.enable_window_aggregation_fusion, } } } diff --git a/src/compute-types/src/plan/lowering.rs b/src/compute-types/src/plan/lowering.rs index eae882ecd91ac..97ecceea80e6d 100644 --- a/src/compute-types/src/plan/lowering.rs +++ b/src/compute-types/src/plan/lowering.rs @@ -37,8 +37,6 @@ pub(super) struct Context { debug_info: LirDebugInfo, /// Whether to enable fusion of MFPs in reductions. enable_reduce_mfp_fusion: bool, - /// Whether to fuse `Reduce` with `FlatMap UnnestList` for better window function performance. - enable_reduce_unnest_list_fusion: bool, } impl Context { @@ -51,7 +49,6 @@ impl Context { id: GlobalId::Transient(0), }, enable_reduce_mfp_fusion: features.enable_reduce_mfp_fusion, - enable_reduce_unnest_list_fusion: features.enable_reduce_unnest_list_fusion, } } @@ -418,9 +415,6 @@ impl Context { // it would be very hard to hunt down all these parts. (For example, key inference // infers the group key as a unique key.) let fused_with_reduce = 'fusion: { - if !self.enable_reduce_unnest_list_fusion { - break 'fusion None; - } if !matches!(func, TableFunc::UnnestList { .. }) { break 'fusion None; } @@ -692,10 +686,9 @@ This is not expected to cause incorrect results, but could indicate a performanc monotonic, expected_group_size, } => { - if self.enable_reduce_unnest_list_fusion - && aggregates - .iter() - .any(|agg| agg.func.can_fuse_with_unnest_list()) + if aggregates + .iter() + .any(|agg| agg.func.can_fuse_with_unnest_list()) { // This case should have been handled at the `MirRelationExpr::FlatMap` case // above. But that has a pretty complicated pattern matching, so it's not diff --git a/src/repr/src/optimize.rs b/src/repr/src/optimize.rs index 97c9c4f82f44e..364cfdd502e1c 100644 --- a/src/repr/src/optimize.rs +++ b/src/repr/src/optimize.rs @@ -116,12 +116,6 @@ optimizer_feature_flags!({ // Reoptimize imported views when building and optimizing a // `DataflowDescription` in the global MIR optimization phase. reoptimize_imported_views: bool, - // Enables the value window function fusion optimization. - enable_value_window_function_fusion: bool, - // See the feature flag of the same name. - enable_reduce_unnest_list_fusion: bool, - // See the feature flag of the same name. - enable_window_aggregation_fusion: bool, // See the feature flag of the same name. enable_reduce_reduction: bool, }); diff --git a/src/sql-parser/src/ast/defs/statement.rs b/src/sql-parser/src/ast/defs/statement.rs index aaaa352fe0bf1..4453aa7a04d46 100644 --- a/src/sql-parser/src/ast/defs/statement.rs +++ b/src/sql-parser/src/ast/defs/statement.rs @@ -2328,9 +2328,6 @@ pub enum ClusterFeatureName { EnableEagerDeltaJoins, EnableVariadicLeftJoinLowering, EnableLetrecFixpointAnalysis, - EnableValueWindowFunctionFusion, - EnableReduceUnnestListFusion, - EnableWindowAggregationFusion, } impl WithOptionName for ClusterFeatureName { @@ -2345,10 +2342,7 @@ impl WithOptionName for ClusterFeatureName { | Self::EnableNewOuterJoinLowering | Self::EnableEagerDeltaJoins | Self::EnableVariadicLeftJoinLowering - | Self::EnableLetrecFixpointAnalysis - | Self::EnableValueWindowFunctionFusion - | Self::EnableReduceUnnestListFusion - | Self::EnableWindowAggregationFusion => false, + | Self::EnableLetrecFixpointAnalysis => false, } } } @@ -3894,9 +3888,6 @@ pub enum ExplainPlanOptionName { EnableEagerDeltaJoins, EnableVariadicLeftJoinLowering, EnableLetrecFixpointAnalysis, - EnableValueWindowFunctionFusion, - EnableReduceUnnestListFusion, - EnableWindowAggregationFusion, } impl WithOptionName for ExplainPlanOptionName { @@ -3930,10 +3921,7 @@ impl WithOptionName for ExplainPlanOptionName { | Self::EnableNewOuterJoinLowering | Self::EnableEagerDeltaJoins | Self::EnableVariadicLeftJoinLowering - | Self::EnableLetrecFixpointAnalysis - | Self::EnableValueWindowFunctionFusion - | Self::EnableReduceUnnestListFusion - | Self::EnableWindowAggregationFusion => false, + | Self::EnableLetrecFixpointAnalysis => false, } } } diff --git a/src/sql/src/plan/lowering.rs b/src/sql/src/plan/lowering.rs index 2097509b34a3b..af1bdbac760eb 100644 --- a/src/sql/src/plan/lowering.rs +++ b/src/sql/src/plan/lowering.rs @@ -136,10 +136,6 @@ pub struct Config { pub enable_new_outer_join_lowering: bool, /// Enable outer join lowering implemented in database-issues#7561. pub enable_variadic_left_join_lowering: bool, - /// See the feature flag of the same name. - pub enable_value_window_function_fusion: bool, - /// See the feature flag of the same name. - pub enable_window_aggregation_fusion: bool, } impl From<&SystemVars> for Config { @@ -147,8 +143,6 @@ impl From<&SystemVars> for Config { Self { enable_new_outer_join_lowering: vars.enable_new_outer_join_lowering(), enable_variadic_left_join_lowering: vars.enable_variadic_left_join_lowering(), - enable_value_window_function_fusion: vars.enable_value_window_function_fusion(), - enable_window_aggregation_fusion: vars.enable_window_aggregation_fusion(), } } } diff --git a/src/sql/src/plan/statement/ddl.rs b/src/sql/src/plan/statement/ddl.rs index 0c75cf2d513aa..2bb01b9d4db6e 100644 --- a/src/sql/src/plan/statement/ddl.rs +++ b/src/sql/src/plan/statement/ddl.rs @@ -4414,10 +4414,7 @@ generate_extracted_config!( (EnableEagerDeltaJoins, Option, Default(None)), (EnableNewOuterJoinLowering, Option, Default(None)), (EnableVariadicLeftJoinLowering, Option, Default(None)), - (EnableLetrecFixpointAnalysis, Option, Default(None)), - (EnableValueWindowFunctionFusion, Option, Default(None)), - (EnableReduceUnnestListFusion, Option, Default(None)), - (EnableWindowAggregationFusion, Option, Default(None)) + (EnableLetrecFixpointAnalysis, Option, Default(None)) ); /// Convert a [`CreateClusterStatement`] into a [`Plan`]. @@ -4554,9 +4551,6 @@ pub fn plan_create_cluster_inner( enable_new_outer_join_lowering, enable_variadic_left_join_lowering, enable_letrec_fixpoint_analysis, - enable_value_window_function_fusion, - enable_reduce_unnest_list_fusion, - enable_window_aggregation_fusion, seen: _, } = ClusterFeatureExtracted::try_from(features)?; let optimizer_feature_overrides = OptimizerFeatureOverrides { @@ -4565,9 +4559,6 @@ pub fn plan_create_cluster_inner( enable_new_outer_join_lowering, enable_variadic_left_join_lowering, enable_letrec_fixpoint_analysis, - enable_value_window_function_fusion, - enable_reduce_unnest_list_fusion, - enable_window_aggregation_fusion, ..Default::default() }; @@ -4662,9 +4653,6 @@ pub fn unplan_create_cluster( enable_new_outer_join_lowering, enable_variadic_left_join_lowering, enable_letrec_fixpoint_analysis, - enable_value_window_function_fusion, - enable_reduce_unnest_list_fusion, - enable_window_aggregation_fusion, enable_reduce_reduction: _, } = optimizer_feature_overrides; let features_extracted = ClusterFeatureExtracted { @@ -4675,9 +4663,6 @@ pub fn unplan_create_cluster( enable_new_outer_join_lowering, enable_variadic_left_join_lowering, enable_letrec_fixpoint_analysis, - enable_value_window_function_fusion, - enable_reduce_unnest_list_fusion, - enable_window_aggregation_fusion, }; let features = features_extracted.into_values(scx.catalog); let availability_zones = if availability_zones.is_empty() { diff --git a/src/sql/src/plan/statement/dml.rs b/src/sql/src/plan/statement/dml.rs index affb4cb71de85..f5c49e50597cf 100644 --- a/src/sql/src/plan/statement/dml.rs +++ b/src/sql/src/plan/statement/dml.rs @@ -368,10 +368,7 @@ generate_extracted_config!( (EnableNewOuterJoinLowering, Option, Default(None)), (EnableEagerDeltaJoins, Option, Default(None)), (EnableVariadicLeftJoinLowering, Option, Default(None)), - (EnableLetrecFixpointAnalysis, Option, Default(None)), - (EnableValueWindowFunctionFusion, Option, Default(None)), - (EnableReduceUnnestListFusion, Option, Default(None)), - (EnableWindowAggregationFusion, Option, Default(None)) + (EnableLetrecFixpointAnalysis, Option, Default(None)) ); impl TryFrom for ExplainConfig { @@ -422,9 +419,6 @@ impl TryFrom for ExplainConfig { enable_cardinality_estimates: Default::default(), persist_fast_path_limit: Default::default(), reoptimize_imported_views: v.reoptimize_imported_views, - enable_value_window_function_fusion: v.enable_value_window_function_fusion, - enable_reduce_unnest_list_fusion: v.enable_reduce_unnest_list_fusion, - enable_window_aggregation_fusion: v.enable_window_aggregation_fusion, enable_reduce_reduction: Default::default(), }, }) diff --git a/src/sql/src/plan/transform_expr.rs b/src/sql/src/plan/transform_expr.rs index 1f047f18a0e0b..524b49e28ab08 100644 --- a/src/sql/src/plan/transform_expr.rs +++ b/src/sql/src/plan/transform_expr.rs @@ -353,14 +353,8 @@ fn column_type( /// columns in the group.) pub fn fuse_window_functions( root: &mut HirRelationExpr, - context: &crate::plan::lowering::Context, + _context: &crate::plan::lowering::Context, ) -> Result<(), RecursionLimitError> { - if !(context.config.enable_value_window_function_fusion - || context.config.enable_window_aggregation_fusion) - { - return Ok(()); - } - impl HirScalarExpr { /// Similar to `MirScalarExpr::support`, but adapted to `HirScalarExpr` in a special way: it /// considers column references that target the root level. @@ -589,7 +583,6 @@ pub fn fuse_window_functions( // encounter these, because we just do one pass, but it's better to be // robust against future code changes.) !matches!(func, ValueWindowFunc::Fused(..)) - && context.config.enable_value_window_function_fusion } HirScalarExpr::Windowing(WindowExpr { func: @@ -598,10 +591,7 @@ pub fn fuse_window_functions( .. }), .. - }) => { - !matches!(func, AggregateFunc::FusedWindowAgg { .. }) - && context.config.enable_window_aggregation_fusion - } + }) => !matches!(func, AggregateFunc::FusedWindowAgg { .. }), _ => false, } }; diff --git a/src/sql/src/session/vars/definitions.rs b/src/sql/src/session/vars/definitions.rs index f9631513c2b8f..a345ecde62de1 100644 --- a/src/sql/src/session/vars/definitions.rs +++ b/src/sql/src/session/vars/definitions.rs @@ -2176,24 +2176,6 @@ feature_flags!( default: false, enable_for_item_parsing: false, }, - { - name: enable_value_window_function_fusion, - desc: "Enables the value window function fusion optimization", - default: true, - enable_for_item_parsing: false, - }, - { - name: enable_window_aggregation_fusion, - desc: "Enables the window aggregation fusion optimization", - default: true, - enable_for_item_parsing: false, - }, - { - name: enable_reduce_unnest_list_fusion, - desc: "Enables fusing `Reduce` with `FlatMap UnnestList` for better window function performance", - default: true, - enable_for_item_parsing: false, - }, { name: enable_continual_task_create, desc: "CREATE CONTINUAL TASK", @@ -2230,9 +2212,6 @@ impl From<&super::SystemVars> for OptimizerFeatures { enable_variadic_left_join_lowering: vars.enable_variadic_left_join_lowering(), enable_letrec_fixpoint_analysis: vars.enable_letrec_fixpoint_analysis(), enable_cardinality_estimates: vars.enable_cardinality_estimates(), - enable_value_window_function_fusion: vars.enable_value_window_function_fusion(), - enable_reduce_unnest_list_fusion: vars.enable_reduce_unnest_list_fusion(), - enable_window_aggregation_fusion: vars.enable_window_aggregation_fusion(), enable_reduce_reduction: vars.enable_reduce_reduction(), persist_fast_path_limit: vars.persist_fast_path_limit(), reoptimize_imported_views: false, diff --git a/test/sqllogictest/window_funcs.slt b/test/sqllogictest/window_funcs.slt index b48c207077b89..cac1be204fe60 100644 --- a/test/sqllogictest/window_funcs.slt +++ b/test/sqllogictest/window_funcs.slt @@ -12,11 +12,6 @@ mode cockroach -simple conn=mz_system,user=mz_system -ALTER SYSTEM SET enable_reduce_unnest_list_fusion = true ----- -COMPLETE 0 - statement ok CREATE TABLE t(x string); @@ -7584,60 +7579,6 @@ ORDER BY x,y; 15 16 1111 240 2222 31 14 31 17 18 1111 306 2222 35 16 35 -simple conn=mz_system,user=mz_system -ALTER SYSTEM SET enable_value_window_function_fusion = false ----- -COMPLETE 0 - -simple conn=mz_system,user=mz_system -ALTER SYSTEM SET enable_window_aggregation_fusion = false ----- -COMPLETE 0 - -query T multiline -EXPLAIN -SELECT - *, - lag(x) OVER (), - lag(y) OVER (), - sum(x) OVER (), - min(x) OVER () -FROM t7 -ORDER BY x,y; ----- -Explained Query: - Finish order_by=[#0 asc nulls_last, #1 asc nulls_last] output=[#0..=#5] - Project (#3, #4, #8, #7, #6, #5) - Map (record_get[1](#1), record_get[0](#2), record_get[1](#2), record_get[3](#2), record_get[5](#2), record_get[7](#2), record_get[0](#1)) - FlatMap unnest_list(#0) - Reduce aggregates=[lag[order_by=[]](row(row(row(record_get[0](record_get[1](#0)), record_get[1](record_get[1](#0)), record_get[2](record_get[1](#0)), record_get[3](record_get[1](#0)), record_get[4](record_get[1](#0)), record_get[5](record_get[1](#0)), record_get[0](#0), record_get[0](#0)), row(record_get[0](record_get[1](#0)), 1, null))))] - Project (#1) - FlatMap unnest_list(#0) - Reduce aggregates=[lag[order_by=[]](row(row(row(record_get[0](record_get[1](#0)), record_get[1](record_get[1](#0)), record_get[2](record_get[1](#0)), record_get[3](record_get[1](#0)), record_get[0](#0), record_get[0](#0)), row(record_get[1](record_get[1](#0)), 1, null))))] - Project (#1) - FlatMap unnest_list(#0) - Reduce aggregates=[window_agg[sum order_by=[]](row(row(row(record_get[0](record_get[1](#0)), record_get[1](record_get[1](#0)), record_get[0](#0), record_get[0](#0)), record_get[0](record_get[1](#0)))))] - Project (#1) - FlatMap unnest_list(#0) - Reduce aggregates=[window_agg[min order_by=[]](row(row(row(#0, #1), #0)))] - ReadStorage materialize.public.t7 - -Source materialize.public.t7 - -Target cluster: quickstart - -EOF - -simple conn=mz_system,user=mz_system -ALTER SYSTEM SET enable_value_window_function_fusion = true ----- -COMPLETE 0 - -simple conn=mz_system,user=mz_system -ALTER SYSTEM SET enable_window_aggregation_fusion = true ----- -COMPLETE 0 - query T multiline EXPLAIN SELECT @@ -7706,7 +7647,8 @@ ORDER BY x,y,l; 13 14 11 15 16 13 -## Check some LIR plans that the optimization guarded by `enable_reduce_unnest_list_fusion` happens. +## Check some LIR plans that the optimization of fusing `Reduce` with `FlatMap UnnestList` happens. +## https://github.com/MaterializeInc/materialize/pull/29554 ## These should show `fused_unnest_list=true`. # Simple situation @@ -7893,192 +7835,6 @@ Target cluster: quickstart EOF -## Run some tests also with `enable_reduce_unnest_list_fusion` disabled. -simple conn=mz_system,user=mz_system -ALTER SYSTEM SET enable_reduce_unnest_list_fusion = false ----- -COMPLETE 0 - -# This is a new test. -query IIIIIIIIIIIIII -SELECT - *, - first_value( - lag(x*x,y,1111) OVER (PARTITION BY x ORDER BY y) - ) OVER (PARTITION BY x ORDER BY y), - x*y, - last_value( - lag(x*x,y,2222) OVER (PARTITION BY x ORDER BY y) - ) OVER (PARTITION BY x ORDER BY y+y), - last_value(x+y) OVER (PARTITION BY x ORDER BY y+y), - lag(y) OVER (ORDER BY x), - row_number() OVER (ORDER BY x), - rank() OVER (ORDER BY x), - dense_rank() OVER (ORDER BY x), - sum(y+3) OVER (ORDER BY x), - min(y+4) OVER (PARTITION BY x%2 ORDER BY x), - x+y, - sum(y+5) OVER (ORDER BY x) -FROM t7 -ORDER BY x,y; ----- -1 2 1111 2 2222 3 NULL 1 1 1 5 6 3 7 -3 NULL NULL NULL NULL NULL 2 2 2 2 5 6 NULL 7 -5 6 1111 30 2222 11 NULL 3 3 3 14 6 11 18 -7 8 1111 56 2222 15 6 4 4 4 25 6 15 31 -9 NULL NULL NULL NULL NULL 8 5 5 5 25 6 NULL 31 -10 -50 1111 -500 2222 -40 NULL 6 6 6 -59 -46 -40 -49 -10 -40 1111 -400 2222 -30 -50 7 6 6 -59 -46 -30 -49 -11 NULL NULL NULL NULL NULL -40 8 8 7 -59 6 NULL -49 -13 14 1111 182 2222 27 NULL 9 9 8 -42 6 27 -30 -15 16 1111 240 2222 31 14 10 10 9 -23 6 31 -9 -17 18 1111 306 2222 35 16 11 11 10 -2 6 35 14 - -# These are copied from above. -query III -SELECT * -FROM ( - SELECT *, lag(x) OVER (ORDER BY x) AS l - FROM t7 -) -WHERE l/2 < 7 -ORDER BY x,y,l; ----- -3 NULL 1 -5 6 3 -7 8 5 -9 NULL 7 -10 -50 9 -10 -40 10 -11 NULL 10 -13 14 11 -15 16 13 - -query IRRB -WITH - simple AS ( - SELECT - x%5 AS x5_simple, - avg(y) OVER (PARTITION BY x%5) AS avg_simple - FROM t7 - ), - complicated AS ( -- array_agg, then do an unnest and global agg in a subquery in a SELECT - WITH - array_agg AS ( - SELECT - x%5 AS x5, - array_agg(y) OVER (PARTITION BY x%5) AS l - FROM t7 - ) - SELECT - x5 AS x5_complicated, - ( - SELECT avg(uy) - FROM unnest(l) AS uy - ) AS avg_complicated - FROM array_agg - ) -SELECT DISTINCT - x5_simple, - avg_simple, - avg_complicated, - avg_simple = avg_complicated -FROM simple, complicated -WHERE x5_simple = x5_complicated -ORDER BY x5_simple; ----- -0 -17 -17 true -1 2 2 true -2 13 13 true -3 14 14 true -4 NULL NULL NULL - -query IIIIIIIIIIIIIIIIIIII -select - x, - y, - lag(y) over (partition by x%4 order by x) as lag1, - lag(y) respect nulls over (partition by x%4 order by x) as lag1_resp, - lag(y) ignore nulls over (partition by x%4 order by x) as lag1_ign, - lead(y) over (partition by x%4 order by x) as lead1, - lead(y) ignore nulls over (partition by x%4 order by x) as lead1_ign, - lag(y, 2) over (partition by x%4 order by x) as lag2, - lag(y, 2) ignore nulls over (partition by x%4 order by x) as lag2_ign, - lead(y, 2) over (partition by x%4 order by x) as lead2, - lead(y, 2) ignore nulls over (partition by x%4 order by x) as lead2_ign, - lag(y, 2, -1) ignore nulls over (partition by x%4 order by x) as lag2_ign_def, - lead(y, 2, -1) ignore nulls over (partition by x%4 order by x) as lead2_ign_def, - lag(y, 2, 16) ignore nulls over (partition by x%4 order by x) as lag2_ign_def16, - lead(y, 2, 16) ignore nulls over (partition by x%4 order by x) as lead2_ign_def16, - lag(y, -1, 100) ignore nulls over (partition by x%4 order by x) as lag_neg_offset, - lead(y, -2, 100) ignore nulls over (partition by x%4 order by x) as lead_neg_offset, - lag(y, y/5+1) ignore nulls over (partition by x%4 order by x) as lag_dynamic_offset, - lead(y, y/5+1) ignore nulls over (partition by x%4 order by x) as lead_dynamic_offset, - lag(y, null) ignore nulls over (partition by x%4 order by x) as lag_literal_null_offset -from t6 -order by x%4, x; ----- -1 2 NULL NULL NULL 6 6 NULL NULL NULL 14 -1 14 16 14 6 100 NULL 6 NULL -5 6 2 2 2 NULL 14 NULL NULL 14 18 -1 18 16 18 14 100 NULL 18 NULL -9 NULL 6 6 6 14 14 2 2 18 18 2 18 2 18 14 2 NULL NULL NULL -13 14 NULL NULL 6 18 18 6 2 NULL NULL 2 -1 2 16 18 2 NULL NULL NULL -17 18 14 14 14 NULL NULL NULL 6 NULL NULL 6 -1 6 16 100 6 NULL NULL NULL -3 NULL NULL NULL NULL 8 8 NULL NULL NULL 16 -1 16 16 16 8 100 NULL NULL NULL -7 8 NULL NULL NULL NULL 16 NULL NULL 16 NULL -1 -1 16 16 16 100 NULL NULL NULL -11 NULL 8 8 8 16 16 NULL NULL NULL NULL -1 -1 16 16 16 100 NULL NULL NULL -15 16 NULL NULL 8 NULL NULL 8 NULL NULL NULL -1 -1 16 16 100 100 NULL NULL NULL - -# Run the same test with also `enable_value_window_function_fusion` disabled. -simple conn=mz_system,user=mz_system -ALTER SYSTEM SET enable_value_window_function_fusion = false ----- -COMPLETE 0 - -query IIIIIIIIIIIIIIIIIIII -select - x, - y, - lag(y) over (partition by x%4 order by x) as lag1, - lag(y) respect nulls over (partition by x%4 order by x) as lag1_resp, - lag(y) ignore nulls over (partition by x%4 order by x) as lag1_ign, - lead(y) over (partition by x%4 order by x) as lead1, - lead(y) ignore nulls over (partition by x%4 order by x) as lead1_ign, - lag(y, 2) over (partition by x%4 order by x) as lag2, - lag(y, 2) ignore nulls over (partition by x%4 order by x) as lag2_ign, - lead(y, 2) over (partition by x%4 order by x) as lead2, - lead(y, 2) ignore nulls over (partition by x%4 order by x) as lead2_ign, - lag(y, 2, -1) ignore nulls over (partition by x%4 order by x) as lag2_ign_def, - lead(y, 2, -1) ignore nulls over (partition by x%4 order by x) as lead2_ign_def, - lag(y, 2, 16) ignore nulls over (partition by x%4 order by x) as lag2_ign_def16, - lead(y, 2, 16) ignore nulls over (partition by x%4 order by x) as lead2_ign_def16, - lag(y, -1, 100) ignore nulls over (partition by x%4 order by x) as lag_neg_offset, - lead(y, -2, 100) ignore nulls over (partition by x%4 order by x) as lead_neg_offset, - lag(y, y/5+1) ignore nulls over (partition by x%4 order by x) as lag_dynamic_offset, - lead(y, y/5+1) ignore nulls over (partition by x%4 order by x) as lead_dynamic_offset, - lag(y, null) ignore nulls over (partition by x%4 order by x) as lag_literal_null_offset -from t6 -order by x%4, x; ----- -1 2 NULL NULL NULL 6 6 NULL NULL NULL 14 -1 14 16 14 6 100 NULL 6 NULL -5 6 2 2 2 NULL 14 NULL NULL 14 18 -1 18 16 18 14 100 NULL 18 NULL -9 NULL 6 6 6 14 14 2 2 18 18 2 18 2 18 14 2 NULL NULL NULL -13 14 NULL NULL 6 18 18 6 2 NULL NULL 2 -1 2 16 18 2 NULL NULL NULL -17 18 14 14 14 NULL NULL NULL 6 NULL NULL 6 -1 6 16 100 6 NULL NULL NULL -3 NULL NULL NULL NULL 8 8 NULL NULL NULL 16 -1 16 16 16 8 100 NULL NULL NULL -7 8 NULL NULL NULL NULL 16 NULL NULL 16 NULL -1 -1 16 16 16 100 NULL NULL NULL -11 NULL 8 8 8 16 16 NULL NULL NULL NULL -1 -1 16 16 16 100 NULL NULL NULL -15 16 NULL NULL 8 NULL NULL 8 NULL NULL NULL -1 -1 16 16 100 100 NULL NULL NULL - -simple conn=mz_system,user=mz_system -ALTER SYSTEM SET enable_value_window_function_fusion = true ----- -COMPLETE 0 - -simple conn=mz_system,user=mz_system -ALTER SYSTEM SET enable_reduce_unnest_list_fusion = true ----- -COMPLETE 0 - ## Window functions on big relations. statement ok