Skip to content

Commit 779f893

Browse files
committed
Add test to demonstrate bug in SingleTimeMonotonic
1 parent b441fcb commit 779f893

1 file changed

Lines changed: 159 additions & 0 deletions

File tree

test/sqllogictest/transform/relax_must_consolidate.slt

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,3 +1203,162 @@ Explained Query:
12031203
Target cluster: quickstart
12041204

12051205
EOF
1206+
1207+
simple conn=mz_system,user=mz_system
1208+
ALTER SYSTEM SET enable_repeat_row = true
1209+
----
1210+
COMPLETE 0
1211+
1212+
simple conn=mz_system,user=mz_system
1213+
ALTER SYSTEM SET enable_repeat_row_non_negative = true
1214+
----
1215+
COMPLETE 0
1216+
1217+
statement ok
1218+
CREATE SOURCE mono_src FROM WEBHOOK BODY FORMAT TEXT;
1219+
1220+
# Regression test for https://github.com/MaterializeInc/database-issues/issues/11310
1221+
# Relies on RelaxMustConsolidate's SingleTimeMonotonic correctly handling FlatMap's TableFunc being !preserves_monotonicity.
1222+
query T multiline
1223+
EXPLAIN PHYSICAL PLAN AS VERBOSE TEXT FOR
1224+
SELECT MAX(body) FROM mono_src, repeat_row(length(body));
1225+
----
1226+
Explained Query:
1227+
With
1228+
cte l0 =
1229+
Reduce::Hierarchical
1230+
aggr_funcs=[max]
1231+
monotonic
1232+
key_plan
1233+
project=()
1234+
val_plan=id
1235+
FlatMap repeat_row(integer_to_bigint(char_length(#0{body})))
1236+
Get::PassArrangements materialize.public.mono_src
1237+
raw=true
1238+
Return
1239+
Union
1240+
ArrangeBy
1241+
input_key=[]
1242+
raw=true
1243+
Get::PassArrangements l0
1244+
raw=false
1245+
arrangements[0]={ key=[], permutation=id, thinning=(#0) }
1246+
Mfp
1247+
project=(#0)
1248+
map=(null)
1249+
Union consolidate_output=true
1250+
Negate
1251+
Get::Arrangement l0
1252+
project=()
1253+
key=
1254+
raw=false
1255+
arrangements[0]={ key=[], permutation=id, thinning=(#0) }
1256+
Constant
1257+
- ()
1258+
1259+
Source materialize.public.mono_src
1260+
1261+
Target cluster: quickstart
1262+
1263+
EOF
1264+
1265+
# Relies on RelaxMustConsolidate's SingleTimeMonotonic correctly handling negative diffs in Constants.
1266+
query T multiline
1267+
EXPLAIN PHYSICAL PLAN AS VERBOSE TEXT FOR
1268+
SELECT MAX(body) FROM mono_src, repeat_row(-1);
1269+
----
1270+
Explained Query:
1271+
With
1272+
cte l0 =
1273+
Reduce::Hierarchical
1274+
aggr_funcs=[max]
1275+
monotonic
1276+
must_consolidate
1277+
key_plan
1278+
project=()
1279+
val_plan=id
1280+
Join::Linear
1281+
linear_stage[0]
1282+
lookup={ relation=1, key=[] }
1283+
stream={ key=[], thinning=(#0) }
1284+
source={ relation=0, key=[] }
1285+
ArrangeBy
1286+
raw=true
1287+
arrangements[0]={ key=[], permutation=id, thinning=(#0) }
1288+
Get::PassArrangements materialize.public.mono_src
1289+
raw=true
1290+
ArrangeBy
1291+
raw=true
1292+
arrangements[0]={ key=[], permutation=id, thinning=() }
1293+
Constant
1294+
- (() x -1)
1295+
Return
1296+
Union
1297+
ArrangeBy
1298+
input_key=[]
1299+
raw=true
1300+
Get::PassArrangements l0
1301+
raw=false
1302+
arrangements[0]={ key=[], permutation=id, thinning=(#0) }
1303+
Mfp
1304+
project=(#0)
1305+
map=(null)
1306+
Union consolidate_output=true
1307+
Negate
1308+
Get::Arrangement l0
1309+
project=()
1310+
key=
1311+
raw=false
1312+
arrangements[0]={ key=[], permutation=id, thinning=(#0) }
1313+
Constant
1314+
- ()
1315+
1316+
Source materialize.public.mono_src
1317+
1318+
Target cluster: quickstart
1319+
1320+
EOF
1321+
1322+
# Relies on `repeat_row_non_negative` being marked as `preserves_monotonicity` (as opposed to `repeat_row`).
1323+
query T multiline
1324+
EXPLAIN PHYSICAL PLAN AS VERBOSE TEXT FOR
1325+
SELECT MAX(body) FROM mono_src, repeat_row_non_negative(length(body));
1326+
----
1327+
Explained Query:
1328+
With
1329+
cte l0 =
1330+
Reduce::Hierarchical
1331+
aggr_funcs=[max]
1332+
monotonic
1333+
key_plan
1334+
project=()
1335+
val_plan=id
1336+
FlatMap repeat_row_non_negative(integer_to_bigint(char_length(#0{body})))
1337+
Get::PassArrangements materialize.public.mono_src
1338+
raw=true
1339+
Return
1340+
Union
1341+
ArrangeBy
1342+
input_key=[]
1343+
raw=true
1344+
Get::PassArrangements l0
1345+
raw=false
1346+
arrangements[0]={ key=[], permutation=id, thinning=(#0) }
1347+
Mfp
1348+
project=(#0)
1349+
map=(null)
1350+
Union consolidate_output=true
1351+
Negate
1352+
Get::Arrangement l0
1353+
project=()
1354+
key=
1355+
raw=false
1356+
arrangements[0]={ key=[], permutation=id, thinning=(#0) }
1357+
Constant
1358+
- ()
1359+
1360+
Source materialize.public.mono_src
1361+
1362+
Target cluster: quickstart
1363+
1364+
EOF

0 commit comments

Comments
 (0)