Skip to content

Commit 97fbe33

Browse files
authored
Merge pull request #31471 from ggevay/aoc-slt-tweak
Tweak aoc slts to use more EXPLAIN options
2 parents baf05bc + 236beec commit 97fbe33

24 files changed

+4322
-3822
lines changed

test/sqllogictest/advent-of-code/2023/aoc_1201.slt

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ FROM (
3838
278
3939

4040
query T multiline
41-
EXPLAIN OPTIMIZED PLAN FOR SELECT SUM(LEFT(r, 1)::int * 10 + RIGHT(r, 1)::int) AS part1
41+
EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) FOR
42+
SELECT SUM(LEFT(r, 1)::int * 10 + RIGHT(r, 1)::int) AS part1
4243
FROM (
4344
SELECT regexp_replace(input, '[^\d]', '', 'g') AS r
4445
FROM aoc_1201
@@ -47,17 +48,17 @@ FROM (
4748
Explained Query:
4849
With
4950
cte l0 =
50-
Reduce aggregates=[sum(((text_to_integer(left(regexp_replace["[^\d]", case_insensitive=false, limit=0](#0, ""), 1)) * 10) + text_to_integer(right(regexp_replace["[^\d]", case_insensitive=false, limit=0](#0, ""), 1))))]
51-
ReadStorage materialize.public.aoc_1201
52-
Return
53-
Union
54-
Get l0
55-
Map (null)
56-
Union
57-
Negate
58-
Project ()
59-
Get l0
60-
Constant
51+
Reduce aggregates=[sum(((text_to_integer(left(regexp_replace["[^\d]", case_insensitive=false, limit=0](#0{input}, ""), 1)) * 10) + text_to_integer(right(regexp_replace["[^\d]", case_insensitive=false, limit=0](#0{input}, ""), 1))))] // { arity: 1 }
52+
ReadStorage materialize.public.aoc_1201 // { arity: 1 }
53+
Return // { arity: 1 }
54+
Union // { arity: 1 }
55+
Get l0 // { arity: 1 }
56+
Map (null) // { arity: 1 }
57+
Union // { arity: 0 }
58+
Negate // { arity: 0 }
59+
Project () // { arity: 0 }
60+
Get l0 // { arity: 1 }
61+
Constant // { arity: 0 }
6162
- ()
6263

6364
Source materialize.public.aoc_1201
@@ -97,7 +98,8 @@ WHERE first.line = last.line
9798
391
9899

99100
query T multiline
100-
EXPLAIN OPTIMIZED PLAN FOR WITH
101+
EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) FOR
102+
WITH
101103
lines AS (
102104
SELECT regexp_split_to_table(input, '\n') AS line
103105
FROM aoc_1201
@@ -127,23 +129,27 @@ WHERE first.line = last.line
127129
Explained Query:
128130
With
129131
cte l0 =
130-
Project (#0, #1, #4)
131-
Join on=(#3 = substr(#0, #1, #2)) type=delta
132-
ArrangeBy keys=[[]]
133-
FlatMap generate_series(1, char_length(#0), 1)
134-
Project (#1)
135-
Filter (#1) IS NOT NULL
136-
FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0))
137-
ReadStorage materialize.public.aoc_1201
138-
ArrangeBy keys=[[]]
139-
Constant
132+
Project (#0, #1, #4) // { arity: 3 }
133+
Join on=(#3 = substr(#0, #1, #2)) type=delta // { arity: 5 }
134+
implementation
135+
%0 » %1[×] » %2[#0]UK
136+
%1 » %0[×] » %2[#0]UK
137+
%2 » %0[×] » %1[×]
138+
ArrangeBy keys=[[]] // { arity: 2 }
139+
FlatMap generate_series(1, char_length(#0), 1) // { arity: 2 }
140+
Project (#1) // { arity: 1 }
141+
Filter (#1) IS NOT NULL // { arity: 2 }
142+
FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0{input})) // { arity: 2 }
143+
ReadStorage materialize.public.aoc_1201 // { arity: 1 }
144+
ArrangeBy keys=[[]] // { arity: 1 }
145+
Constant // { arity: 1 }
140146
- (1)
141147
- (2)
142148
- (3)
143149
- (4)
144150
- (5)
145-
ArrangeBy keys=[[#0]]
146-
Constant
151+
ArrangeBy keys=[[#0]] // { arity: 2 }
152+
Constant // { arity: 2 }
147153
- ("0", 0)
148154
- ("1", 1)
149155
- ("2", 2)
@@ -165,26 +171,28 @@ Explained Query:
165171
- ("seven", 7)
166172
- ("three", 3)
167173
cte l1 =
168-
Reduce aggregates=[sum(((#0 * 10) + #1))]
169-
Project (#1, #3)
170-
Join on=(#0 = #2) type=differential
171-
ArrangeBy keys=[[#0]]
172-
Project (#0, #2)
173-
TopK group_by=[#0] order_by=[#1 asc nulls_last] limit=1
174-
Get l0
175-
ArrangeBy keys=[[#0]]
176-
Project (#0, #2)
177-
TopK group_by=[#0] order_by=[#1 desc nulls_first] limit=1
178-
Get l0
179-
Return
180-
Union
181-
Get l1
182-
Map (null)
183-
Union
184-
Negate
185-
Project ()
186-
Get l1
187-
Constant
174+
Reduce aggregates=[sum(((#0 * 10) + #1))] // { arity: 1 }
175+
Project (#1, #3) // { arity: 2 }
176+
Join on=(#0 = #2) type=differential // { arity: 4 }
177+
implementation
178+
%0[#0]UK » %1[#0]UK
179+
ArrangeBy keys=[[#0]] // { arity: 2 }
180+
Project (#0, #2) // { arity: 2 }
181+
TopK group_by=[#0] order_by=[#1 asc nulls_last] limit=1 // { arity: 3 }
182+
Get l0 // { arity: 3 }
183+
ArrangeBy keys=[[#0]] // { arity: 2 }
184+
Project (#0, #2) // { arity: 2 }
185+
TopK group_by=[#0] order_by=[#1 desc nulls_first] limit=1 // { arity: 3 }
186+
Get l0 // { arity: 3 }
187+
Return // { arity: 1 }
188+
Union // { arity: 1 }
189+
Get l1 // { arity: 1 }
190+
Map (null) // { arity: 1 }
191+
Union // { arity: 0 }
192+
Negate // { arity: 0 }
193+
Project () // { arity: 0 }
194+
Get l1 // { arity: 1 }
195+
Constant // { arity: 0 }
188196
- ()
189197

190198
Source materialize.public.aoc_1201

0 commit comments

Comments
 (0)