File tree Expand file tree Collapse file tree
src/compute-types/src/plan/interpret
test/sqllogictest/transform Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,12 +139,10 @@ impl Interpreter for SingleTimeMonotonic<'_> {
139139 _input_key : & Option < Vec < MirScalarExpr > > ,
140140 input : Self :: Domain ,
141141 _exprs : & Vec < MirScalarExpr > ,
142- _func : & TableFunc ,
142+ func : & TableFunc ,
143143 _mfp : & MapFilterProject ,
144144 ) -> Self :: Domain {
145- // In a single-time context, we just propagate the monotonicity
146- // status of the input
147- input
145+ PhysicallyMonotonic ( input. 0 && func. preserves_monotonicity ( ) )
148146 }
149147
150148 fn join (
Original file line number Diff line number Diff line change @@ -1217,8 +1217,14 @@ COMPLETE 0
12171217statement ok
12181218CREATE SOURCE mono_src FROM WEBHOOK BODY FORMAT TEXT;
12191219
1220- # Regression test for https://github.com/MaterializeInc/database-issues/issues/11310
1220+ # Regression test for https://github.com/MaterializeInc/database-issues/issues/11310, i.e., that we set the
1221+ # `must_consolidate` flag when `repeat_row` is involved.
12211222# Relies on RelaxMustConsolidate's SingleTimeMonotonic correctly handling FlatMap's TableFunc being !preserves_monotonicity.
1223+ # Note that the plans are still somewhat wrong, in that monotonic operators won't produce correct results when presented
1224+ # with negative accumulations even with the `must_consolidate` flag set. However, the expectation is that they'll have
1225+ # an easier time detecting negative accumulations and cleanly erroring out when the `must_consolidate` flag is set.
1226+ # See also https://github.com/MaterializeInc/materialize/pull/36184 for more discussion, where we considered not
1227+ # choosing monotonic operators when `repeat_row` is involved, but eventually decided to go with the current behavior.
12221228query T multiline
12231229EXPLAIN PHYSICAL PLAN AS VERBOSE TEXT FOR
12241230SELECT MAX(body) FROM mono_src, repeat_row(length(body));
@@ -1229,6 +1235,7 @@ Explained Query:
12291235 Reduce::Hierarchical
12301236 aggr_funcs=[max]
12311237 monotonic
1238+ must_consolidate
12321239 key_plan
12331240 project=()
12341241 val_plan=id
You can’t perform that action at this time.
0 commit comments