Skip to content

Commit efbc8df

Browse files
authored
Merge pull request #17448 from aalexandrov/fix_view_explainee_id
2 parents b6caa4c + 1c5aeb8 commit efbc8df

File tree

10 files changed

+30
-26
lines changed

10 files changed

+30
-26
lines changed

Diff for: src/adapter/src/coord/sequencer.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -2722,6 +2722,11 @@ impl Coordinator {
27222722
trace_plan(&raw_plan);
27232723
});
27242724

2725+
let explainee_id = match explainee {
2726+
Explainee::Dataflow(id) => id,
2727+
Explainee::Query => GlobalId::Explain,
2728+
};
2729+
27252730
// run optimization pipeline
27262731
let decorrelated_plan = raw_plan.optimize_and_lower(&OptimizerConfig {})?;
27272732

@@ -2732,8 +2737,7 @@ impl Coordinator {
27322737
let optimized_plan = self.view_optimizer.optimize(decorrelated_plan)?;
27332738
let mut dataflow = DataflowDesc::new("explanation".to_string());
27342739
self.dataflow_builder(cluster).import_view_into_dataflow(
2735-
// TODO: If explaining a view, pipe the actual id of the view.
2736-
&GlobalId::Explain,
2740+
&explainee_id,
27372741
&optimized_plan,
27382742
&mut dataflow,
27392743
)?;

Diff for: test/sqllogictest/attributes/mir_arity.slt

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ORDER BY t.b LIMIT 10 OFFSET 1);
4242
query T multiline
4343
EXPLAIN OPTIMIZED PLAN WITH(arity) AS TEXT FOR VIEW test1
4444
----
45-
Explained Query:
45+
materialize.public.test1:
4646
Return // { arity: 4 }
4747
Threshold // { arity: 4 }
4848
Union // { arity: 4 }

Diff for: test/sqllogictest/explain/optimized_plan_as_json.slt

+1-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ VIEW ov
866866
{
867867
"plans": [
868868
{
869-
"id": "Explained Query",
869+
"id": "materialize.public.ov",
870870
"plan": {
871871
"TopK": {
872872
"input": {

Diff for: test/sqllogictest/explain/optimized_plan_as_text.slt

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ query T multiline
159159
EXPLAIN OPTIMIZED PLAN AS TEXT FOR
160160
VIEW ov
161161
----
162-
Explained Query:
162+
materialize.public.ov:
163163
TopK order_by=[#1 asc nulls_last, #0 desc nulls_first] limit=5 monotonic=false
164164
Get materialize.public.t
165165

Diff for: test/sqllogictest/explain/physical_plan_as_json.slt

+1-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ VIEW ov
627627
{
628628
"plans": [
629629
{
630-
"id": "Explained Query",
630+
"id": "materialize.public.ov",
631631
"plan": {
632632
"TopK": {
633633
"input": {

Diff for: test/sqllogictest/transform/dataflow.slt

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ EOF
3737
query T multiline
3838
EXPLAIN WITH(arity, join_impls) VIEW foo3
3939
----
40-
Explained Query:
40+
materialize.public.foo3:
4141
Project (#1) // { arity: 1 }
4242
Filter (#0 = 5) AND (#1 = 6) // { arity: 2 }
4343
Get materialize.public.foo // { arity: 2 }
@@ -53,7 +53,7 @@ CREATE DEFAULT INDEX ON foo2
5353
query T multiline
5454
EXPLAIN WITH(arity, join_impls) VIEW foo3
5555
----
56-
Explained Query:
56+
materialize.public.foo3:
5757
Project (#0) // { arity: 1 }
5858
ReadExistingIndex materialize.public.foo2 lookup_value=(6)
5959

Diff for: test/sqllogictest/transform/topk.slt

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ CREATE DEFAULT INDEX ON plan_test1
5353
query T multiline
5454
EXPLAIN WITH(arity, join_impls) VIEW plan_test1
5555
----
56-
Explained Query:
56+
materialize.public.plan_test1:
5757
Project (#4, #0, #1) // { arity: 3 }
5858
Map ((bigint_to_double(#2) / bigint_to_double(case when (#3 = 0) then null else #3 end))) // { arity: 5 }
5959
Reduce group_by=[((#0 + #1) + #2), ((#0 + #1) + #3)] aggregates=[sum(#3), count(#3)] // { arity: 4 }
@@ -102,7 +102,7 @@ create default index on v1
102102
query T multiline
103103
explain with(arity, join_impls) view v1;
104104
----
105-
Explained Query:
105+
materialize.public.v1:
106106
TopK order_by=[#0 asc nulls_last] limit=3 offset=3 monotonic=false // { arity: 2 }
107107
Get materialize.public.t1 // { arity: 2 }
108108

Diff for: test/testdrive/monotonic.td

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ a min max
7474
$ set-regex match=(.User.:\s\d+|\(u\d+\)) replacement=UID
7575

7676
? EXPLAIN PHYSICAL PLAN FOR VIEW v2
77-
Explained Query:
77+
materialize.public.v2:
7878
TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=3
7979
ArrangeBy
8080
input_key=[#0]
@@ -98,7 +98,7 @@ Used Indexes:
9898
> CREATE VIEW v3 AS SELECT * FROM non_dbz_data_indexed ORDER BY b LIMIT 3
9999

100100
? EXPLAIN PHYSICAL PLAN FOR VIEW v3
101-
Explained Query:
101+
materialize.public.v3:
102102
TopK::MonotonicTopK order_by=[#1 asc nulls_last] limit=3
103103
ArrangeBy
104104
input_key=[#0, #1]
@@ -118,7 +118,7 @@ Used Indexes:
118118
> CREATE VIEW v5 AS SELECT * from i4 ORDER BY c LIMIT 2;
119119

120120
? EXPLAIN PHYSICAL PLAN FOR VIEW v5;
121-
Explained Query:
121+
materialize.public.v5:
122122
TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2
123123
ArrangeBy
124124
input_key=[#0]
@@ -138,7 +138,7 @@ Used Indexes:
138138
> CREATE VIEW v7 AS SELECT * from i6 ORDER BY c LIMIT 2;
139139

140140
? EXPLAIN PHYSICAL PLAN FOR VIEW v7;
141-
Explained Query:
141+
materialize.public.v7:
142142
TopK::Basic order_by=[#0 asc nulls_last] limit=2
143143
ArrangeBy
144144
input_key=[#0]
@@ -161,7 +161,7 @@ Used Indexes:
161161
# Propagating monotonicity analysis in a complex situation: (i1, i1) -> i8; (i1, i8) -> i9
162162

163163
? EXPLAIN PHYSICAL PLAN FOR VIEW v10;
164-
Explained Query:
164+
materialize.public.v10:
165165
TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2
166166
ArrangeBy
167167
input_key=[#0]
@@ -180,7 +180,7 @@ Used Indexes:
180180
# Propagating monotonicity analysis through materialized views
181181

182182
? EXPLAIN PHYSICAL PLAN FOR VIEW v11;
183-
Explained Query:
183+
materialize.public.v11:
184184
TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=3
185185
Get::PassArrangements materialize.public.m1
186186
raw=true

Diff for: test/testdrive/render-delta-join.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ count
3131
1
3232

3333
> EXPLAIN WITH(join_impls) VIEW delta_join;
34-
"Explained Query: Project (#0, #1, #0, #3) Filter (#0) IS NOT NULL Join on=(#0 = #2) type=differential implementation %1:t2[#0] » %0:t1[#0]KA ArrangeBy keys=[[#0]] Get t1 ArrangeBy keys=[[#0]] Get t2Used Indexes: - i1 - i2"
34+
"delta_join: Project (#0, #1, #0, #3) Filter (#0) IS NOT NULL Join on=(#0 = #2) type=differential implementation %1:t2[#0] » %0:t1[#0]KA ArrangeBy keys=[[#0]] Get t1 ArrangeBy keys=[[#0]] Get t2Used Indexes: - i1 - i2"
3535

3636
> SELECT count(*) AS count FROM delta_join;
3737
count

Diff for: test/testdrive/source-linear-operators.td

+9-9
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ $ set-regex match=u\d+ replacement=UID
4444
> CREATE DEFAULT INDEX ON v;
4545

4646
? EXPLAIN VIEW v;
47-
Explained Query:
47+
materialize.public.v:
4848
Filter (#0 = 1) AND (#3 = 3)
4949
Get materialize.public.data
5050

@@ -62,7 +62,7 @@ Source materialize.public.data
6262
> CREATE DEFAULT INDEX ON v;
6363

6464
? EXPLAIN VIEW v;
65-
Explained Query:
65+
materialize.public.v:
6666
Project (#1)
6767
Filter (#1 = 1)
6868
Get materialize.public.data
@@ -86,7 +86,7 @@ Source materialize.public.data
8686
> CREATE DEFAULT INDEX ON v
8787

8888
? EXPLAIN VIEW v;
89-
Explained Query:
89+
materialize.public.v:
9090
Project (#1)
9191
Filter (#0 = 1) AND (#3 = 4)
9292
Get materialize.public.data
@@ -105,7 +105,7 @@ Source materialize.public.data
105105
> CREATE DEFAULT INDEX ON v;
106106

107107
? EXPLAIN VIEW v;
108-
Explained Query:
108+
materialize.public.v:
109109
Project (#3)
110110
Filter (#0 = 1) AND (#3 = 4)
111111
Get materialize.public.data
@@ -122,7 +122,7 @@ Source materialize.public.data
122122
> CREATE DEFAULT INDEX ON v;
123123

124124
? EXPLAIN VIEW v;
125-
Explained Query:
125+
materialize.public.v:
126126
Project (#0)
127127
Join on=(#0 = #1) type=differential
128128
ArrangeBy keys=[[#0]]
@@ -148,7 +148,7 @@ Explained Query:
148148
> CREATE DEFAULT INDEX ON v;
149149

150150
? EXPLAIN VIEW v;
151-
Explained Query:
151+
materialize.public.v:
152152
Project (#1)
153153
Join on=(#0 = #2) type=differential
154154
ArrangeBy keys=[[#0]]
@@ -173,7 +173,7 @@ Source materialize.public.data
173173
> CREATE DEFAULT INDEX ON v
174174

175175
? EXPLAIN VIEW v;
176-
Explained Query:
176+
materialize.public.v:
177177
Return
178178
Project (#2)
179179
Join on=(#0 = #1) type=differential
@@ -205,7 +205,7 @@ Source materialize.public.data
205205
> CREATE DEFAULT INDEX ON v;
206206

207207
? EXPLAIN VIEW v;
208-
Explained Query:
208+
materialize.public.v:
209209
Union
210210
Project (#1, #0)
211211
Map (1)
@@ -244,7 +244,7 @@ $ kafka-ingest format=avro topic=data2 schema=${schema}
244244
> CREATE DEFAULT INDEX ON v
245245

246246
? EXPLAIN VIEW v;
247-
Explained Query:
247+
materialize.public.v:
248248
Threshold
249249
Union
250250
Project (#0, #2)

0 commit comments

Comments
 (0)