forked from MaterializeInc/materialize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub-17616.slt
122 lines (110 loc) · 3.33 KB
/
github-17616.slt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
# Regression test for https://github.com/MaterializeInc/materialize/issues/17616
mode cockroach
# reset
statement ok
DROP TABLE IF EXISTS t1 CASCADE
statement ok
DROP TABLE IF EXISTS t2 CASCADE
# schema
statement ok
CREATE TABLE t1(f1 INT, f2 INT, f3 INT)
statement ok
CREATE TABLE t2(f2 INT, f3 INT)
# data
statement ok
INSERT INTO t1 VALUES (1, 2, 3)
statement ok
INSERT INTO t2 VALUES (2, 3)
query T multiline
EXPLAIN DECORRELATED PLAN WITH(arity) FOR
SELECT
sq1.*
FROM
(
SELECT * FROM t1
) AS sq0,
LATERAL(
SELECT
( sq0.f2 * f2 ) as c0,
( SELECT 3 ) as c1,
( sq0.f2 * f2 ) * 2 as c2
FROM t2
) AS sq1
----
Return // { arity: 3 }
Project (#3..=#5) // { arity: 3 }
Filter true // { arity: 6 }
Project (#0..=#2, #4..=#6) // { arity: 6 }
Join on=(#1 = #3) // { arity: 7 }
Get l0 // { arity: 3 }
Project (#0, #3..=#5) // { arity: 4 }
Map ((#3 * 2)) // { arity: 6 }
Project (#0..=#2, #7, #8) // { arity: 5 }
Map ((#0 * #1), #6) // { arity: 9 }
Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) // { arity: 7 }
Get l1 // { arity: 3 }
Union // { arity: 4 }
Get l4 // { arity: 4 }
CrossJoin // { arity: 4 }
Project (#0..=#2) // { arity: 3 }
Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) // { arity: 6 }
Union // { arity: 3 }
Negate // { arity: 3 }
Distinct project=[#0..=#2] // { arity: 3 }
Get l4 // { arity: 4 }
Distinct project=[#0..=#2] // { arity: 3 }
Get l2 // { arity: 3 }
Get l2 // { arity: 3 }
Constant // { arity: 1 }
- (null)
With
cte l4 =
Union // { arity: 4 }
Get l3 // { arity: 4 }
Map (error("more than one record produced in subquery")) // { arity: 4 }
Project (#0..=#2) // { arity: 3 }
Filter (#3 > 1) // { arity: 4 }
Reduce group_by=[#0..=#2] aggregates=[count(*)] // { arity: 4 }
Get l3 // { arity: 4 }
cte l3 =
Project (#0..=#3) // { arity: 4 }
Map (3) // { arity: 4 }
Get l2 // { arity: 3 }
cte l2 =
Distinct project=[#0..=#2] // { arity: 3 }
Get l1 // { arity: 3 }
cte l1 =
CrossJoin // { arity: 3 }
Distinct project=[#1] // { arity: 1 }
Get l0 // { arity: 3 }
Get materialize.public.t2 // { arity: 2 }
cte l0 =
CrossJoin // { arity: 3 }
Constant // { arity: 0 }
- ()
Get materialize.public.t1 // { arity: 3 }
EOF
query III rowsort
SELECT
sq1.*
FROM
(
SELECT * FROM t1
) AS sq0,
LATERAL(
SELECT
( sq0.f2 * f2 ) as c0,
( SELECT 3 ) as c1,
( sq0.f2 * f2 ) * 2 as c2
FROM t2
) AS sq1
----
4 3 8