Skip to content

Commit 39f9f77

Browse files
committed
Parse join relationship
1 parent 0f75273 commit 39f9f77

File tree

8 files changed

+581
-63
lines changed

8 files changed

+581
-63
lines changed
Lines changed: 331 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,331 @@
1+
{
2+
"0": {
3+
"plan": {
4+
"id": "9",
5+
"name": "Output",
6+
"identifier": "[t1_id, t1_a, t2_id, t2_b, t2_c]",
7+
"details": "t1_id := id (2:5)\nt1_a := a (3:5)\nt2_id := id_0 (4:5)\nt2_b := b (5:5)\nt2_c := c (6:5)\n",
8+
"children": [
9+
{
10+
"id": "368",
11+
"name": "RemoteSource",
12+
"identifier": "[1]",
13+
"details": "",
14+
"children": [],
15+
"remoteSources": [
16+
"1"
17+
],
18+
"estimates": []
19+
}
20+
],
21+
"remoteSources": [],
22+
"estimates": [
23+
{
24+
"outputRowCount": "NaN",
25+
"totalSize": "NaN",
26+
"confident": false,
27+
"variableStatistics": {},
28+
"joinNodeStatsEstimate": {
29+
"nullJoinBuildKeyCount": "NaN",
30+
"joinBuildKeyCount": "NaN",
31+
"nullJoinProbeKeyCount": "NaN",
32+
"joinProbeKeyCount": "NaN"
33+
},
34+
"tableWriterNodeStatsEstimate": {
35+
"taskCountIfScaledWriter": "NaN"
36+
},
37+
"partialAggregationStatsEstimate": {
38+
"inputBytes": "NaN",
39+
"outputBytes": "NaN",
40+
"inputRowCount": "NaN",
41+
"outputRowCount": "NaN"
42+
}
43+
}
44+
]
45+
}
46+
},
47+
"1": {
48+
"plan": {
49+
"id": "4",
50+
"name": "InnerJoin",
51+
"identifier": "[(\"expr\" = \"expr_5\")][$hashvalue, $hashvalue_27]",
52+
"details": "Distribution: PARTITIONED\n",
53+
"children": [
54+
{
55+
"id": "366",
56+
"name": "RemoteSource",
57+
"identifier": "[2]",
58+
"details": "",
59+
"children": [],
60+
"remoteSources": [
61+
"2"
62+
],
63+
"estimates": []
64+
},
65+
{
66+
"id": "409",
67+
"name": "LocalExchange",
68+
"identifier": "[HASH][$hashvalue_27] (expr_5)",
69+
"details": "",
70+
"children": [
71+
{
72+
"id": "367",
73+
"name": "RemoteSource",
74+
"identifier": "[3]",
75+
"details": "",
76+
"children": [],
77+
"remoteSources": [
78+
"3"
79+
],
80+
"estimates": []
81+
}
82+
],
83+
"remoteSources": [],
84+
"estimates": [
85+
{
86+
"outputRowCount": 3.0,
87+
"totalSize": "NaN",
88+
"confident": true,
89+
"variableStatistics": {
90+
"expr_5\u003cinteger\u003e": {
91+
"lowValue": "NaN",
92+
"highValue": "NaN",
93+
"nullsFraction": 1.0,
94+
"averageRowSize": "NaN",
95+
"distinctValuesCount": "NaN"
96+
}
97+
},
98+
"joinNodeStatsEstimate": {
99+
"nullJoinBuildKeyCount": "NaN",
100+
"joinBuildKeyCount": "NaN",
101+
"nullJoinProbeKeyCount": "NaN",
102+
"joinProbeKeyCount": "NaN"
103+
},
104+
"tableWriterNodeStatsEstimate": {
105+
"taskCountIfScaledWriter": "NaN"
106+
},
107+
"partialAggregationStatsEstimate": {
108+
"inputBytes": "NaN",
109+
"outputBytes": "NaN",
110+
"inputRowCount": "NaN",
111+
"outputRowCount": "NaN"
112+
}
113+
}
114+
]
115+
}
116+
],
117+
"remoteSources": [],
118+
"estimates": [
119+
{
120+
"outputRowCount": "NaN",
121+
"totalSize": "NaN",
122+
"confident": false,
123+
"variableStatistics": {},
124+
"joinNodeStatsEstimate": {
125+
"nullJoinBuildKeyCount": "NaN",
126+
"joinBuildKeyCount": "NaN",
127+
"nullJoinProbeKeyCount": "NaN",
128+
"joinProbeKeyCount": "NaN"
129+
},
130+
"tableWriterNodeStatsEstimate": {
131+
"taskCountIfScaledWriter": "NaN"
132+
},
133+
"partialAggregationStatsEstimate": {
134+
"inputBytes": "NaN",
135+
"outputBytes": "NaN",
136+
"inputRowCount": "NaN",
137+
"outputRowCount": "NaN"
138+
}
139+
}
140+
]
141+
}
142+
},
143+
"2": {
144+
"plan": {
145+
"id": "446",
146+
"name": "Project",
147+
"identifier": "[projectLocality = LOCAL]",
148+
"details": "$hashvalue_26 := combine_hash(BIGINT'0', COALESCE($operator$hash_code(expr), BIGINT'0')) (10:16)\n",
149+
"children": [
150+
{
151+
"id": "2",
152+
"name": "ScanProject",
153+
"identifier": "[table = TableHandle {connectorId='hive', connectorHandle='HiveTableHandle{schemaName=test_join, tableName=t1, analyzePartitionValues=Optional.empty}', layout='Optional[test_join.t1{}]'}, projectLocality = LOCAL]",
154+
"details": "expr := (a) + (INTEGER'2') (8:6)\nLAYOUT: test_join.t1{}\nid := id:int:0:REGULAR (8:5)\na := a:int:1:REGULAR (8:5)\n",
155+
"children": [],
156+
"remoteSources": [],
157+
"estimates": [
158+
{
159+
"outputRowCount": 3.0,
160+
"totalSize": 30.0,
161+
"confident": true,
162+
"variableStatistics": {},
163+
"joinNodeStatsEstimate": {
164+
"nullJoinBuildKeyCount": "NaN",
165+
"joinBuildKeyCount": "NaN",
166+
"nullJoinProbeKeyCount": "NaN",
167+
"joinProbeKeyCount": "NaN"
168+
},
169+
"tableWriterNodeStatsEstimate": {
170+
"taskCountIfScaledWriter": "NaN"
171+
},
172+
"partialAggregationStatsEstimate": {
173+
"inputBytes": "NaN",
174+
"outputBytes": "NaN",
175+
"inputRowCount": "NaN",
176+
"outputRowCount": "NaN"
177+
}
178+
},
179+
{
180+
"outputRowCount": 3.0,
181+
"totalSize": "NaN",
182+
"confident": true,
183+
"variableStatistics": {},
184+
"joinNodeStatsEstimate": {
185+
"nullJoinBuildKeyCount": "NaN",
186+
"joinBuildKeyCount": "NaN",
187+
"nullJoinProbeKeyCount": "NaN",
188+
"joinProbeKeyCount": "NaN"
189+
},
190+
"tableWriterNodeStatsEstimate": {
191+
"taskCountIfScaledWriter": "NaN"
192+
},
193+
"partialAggregationStatsEstimate": {
194+
"inputBytes": "NaN",
195+
"outputBytes": "NaN",
196+
"inputRowCount": "NaN",
197+
"outputRowCount": "NaN"
198+
}
199+
}
200+
]
201+
}
202+
],
203+
"remoteSources": [],
204+
"estimates": [
205+
{
206+
"outputRowCount": 3.0,
207+
"totalSize": "NaN",
208+
"confident": true,
209+
"variableStatistics": {},
210+
"joinNodeStatsEstimate": {
211+
"nullJoinBuildKeyCount": "NaN",
212+
"joinBuildKeyCount": "NaN",
213+
"nullJoinProbeKeyCount": "NaN",
214+
"joinProbeKeyCount": "NaN"
215+
},
216+
"tableWriterNodeStatsEstimate": {
217+
"taskCountIfScaledWriter": "NaN"
218+
},
219+
"partialAggregationStatsEstimate": {
220+
"inputBytes": "NaN",
221+
"outputBytes": "NaN",
222+
"inputRowCount": "NaN",
223+
"outputRowCount": "NaN"
224+
}
225+
}
226+
]
227+
}
228+
},
229+
"3": {
230+
"plan": {
231+
"id": "447",
232+
"name": "Project",
233+
"identifier": "[projectLocality = LOCAL]",
234+
"details": "$hashvalue_29 := combine_hash(BIGINT'0', COALESCE($operator$hash_code(expr_5), BIGINT'0')) (10:33)\n",
235+
"children": [
236+
{
237+
"id": "3",
238+
"name": "ScanProject",
239+
"identifier": "[table = TableHandle {connectorId='hive', connectorHandle='HiveTableHandle{schemaName=test_join, tableName=t2, analyzePartitionValues=Optional.empty}', layout='Optional[test_join.t2{}]'}, projectLocality = LOCAL]",
240+
"details": "expr_5 := ((b) + (INTEGER'1')) - ((INTEGER'2') * (abs(c))) (10:6)\nLAYOUT: test_join.t2{}\nc := c:int:2:REGULAR (10:5)\nid_0 := id:int:0:REGULAR (10:5)\nb := b:int:1:REGULAR (10:5)\n",
241+
"children": [],
242+
"remoteSources": [],
243+
"estimates": [
244+
{
245+
"outputRowCount": 3.0,
246+
"totalSize": 45.0,
247+
"confident": true,
248+
"variableStatistics": {},
249+
"joinNodeStatsEstimate": {
250+
"nullJoinBuildKeyCount": "NaN",
251+
"joinBuildKeyCount": "NaN",
252+
"nullJoinProbeKeyCount": "NaN",
253+
"joinProbeKeyCount": "NaN"
254+
},
255+
"tableWriterNodeStatsEstimate": {
256+
"taskCountIfScaledWriter": "NaN"
257+
},
258+
"partialAggregationStatsEstimate": {
259+
"inputBytes": "NaN",
260+
"outputBytes": "NaN",
261+
"inputRowCount": "NaN",
262+
"outputRowCount": "NaN"
263+
}
264+
},
265+
{
266+
"outputRowCount": 3.0,
267+
"totalSize": "NaN",
268+
"confident": true,
269+
"variableStatistics": {
270+
"expr_5\u003cinteger\u003e": {
271+
"lowValue": "NaN",
272+
"highValue": "NaN",
273+
"nullsFraction": 1.0,
274+
"averageRowSize": "NaN",
275+
"distinctValuesCount": "NaN"
276+
}
277+
},
278+
"joinNodeStatsEstimate": {
279+
"nullJoinBuildKeyCount": "NaN",
280+
"joinBuildKeyCount": "NaN",
281+
"nullJoinProbeKeyCount": "NaN",
282+
"joinProbeKeyCount": "NaN"
283+
},
284+
"tableWriterNodeStatsEstimate": {
285+
"taskCountIfScaledWriter": "NaN"
286+
},
287+
"partialAggregationStatsEstimate": {
288+
"inputBytes": "NaN",
289+
"outputBytes": "NaN",
290+
"inputRowCount": "NaN",
291+
"outputRowCount": "NaN"
292+
}
293+
}
294+
]
295+
}
296+
],
297+
"remoteSources": [],
298+
"estimates": [
299+
{
300+
"outputRowCount": 3.0,
301+
"totalSize": "NaN",
302+
"confident": true,
303+
"variableStatistics": {
304+
"expr_5\u003cinteger\u003e": {
305+
"lowValue": "NaN",
306+
"highValue": "NaN",
307+
"nullsFraction": 1.0,
308+
"averageRowSize": "NaN",
309+
"distinctValuesCount": "NaN"
310+
}
311+
},
312+
"joinNodeStatsEstimate": {
313+
"nullJoinBuildKeyCount": "NaN",
314+
"joinBuildKeyCount": "NaN",
315+
"nullJoinProbeKeyCount": "NaN",
316+
"joinProbeKeyCount": "NaN"
317+
},
318+
"tableWriterNodeStatsEstimate": {
319+
"taskCountIfScaledWriter": "NaN"
320+
},
321+
"partialAggregationStatsEstimate": {
322+
"inputBytes": "NaN",
323+
"outputBytes": "NaN",
324+
"inputRowCount": "NaN",
325+
"outputRowCount": "NaN"
326+
}
327+
}
328+
]
329+
}
330+
}
331+
}

presto/plan_node/arithmetics.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
-- Create tables
2+
CREATE TABLE t1 (
3+
id INT,
4+
a INT
5+
);
6+
7+
CREATE TABLE t2 (
8+
id INT,
9+
b INT,
10+
c INT
11+
);
12+
13+
-- Insert sample data
14+
INSERT INTO t1 (id, a) VALUES
15+
(1, 15),
16+
(2, 25),
17+
(3, 35);
18+
19+
INSERT INTO t2 (id, b, c) VALUES
20+
(1, 5, 10),
21+
(2, 10, 15),
22+
(3, 15, 20);
23+
24+
-- Perform the join
25+
SELECT
26+
t1.id AS t1_id,
27+
t1.a AS t1_a,
28+
t2.id AS t2_id,
29+
t2.b AS t2_b,
30+
t2.c AS t2_c
31+
FROM
32+
t1
33+
JOIN
34+
t2 ON t1.a + 2 = (t2.b + 1) - 2 * ABS(t2.c);

0 commit comments

Comments
 (0)