blob: 45c9cbd48feaa61b301d485d2fc54052a544377d [file] [log] [blame]
# Copyright 2016, Quickstep Research Group, Computer Sciences Department,
# University of Wisconsin—Madison.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[default physical_plan]
SELECT a.z
FROM a JOIN b ON a.w = b.w
JOIN c ON a.x = c.x
JOIN d ON a.y = d.y;
--
TopLevelPlan
+-plan=HashJoin
| +-left=HashJoin
| | +-left=HashJoin
| | | +-left=TableReference[relation=a]
| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
| | | +-right=TableReference[relation=b]
| | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
| | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
| | | +-project_expressions=
| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
| | | +-left_join_attributes=
| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | | +-right_join_attributes=
| | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
| | +-right=TableReference[relation=c]
| | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
| | +-project_expressions=
| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
| | +-left_join_attributes=
| | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | +-right_join_attributes=
| | +-AttributeReference[id=6,name=x,relation=c,type=Int]
| +-right=TableReference[relation=d]
| | +-AttributeReference[id=8,name=y,relation=d,type=Int]
| | +-AttributeReference[id=9,name=z,relation=d,type=Int]
| +-project_expressions=
| | +-AttributeReference[id=3,name=z,relation=a,type=Int]
| +-left_join_attributes=
| | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| +-right_join_attributes=
| +-AttributeReference[id=8,name=y,relation=d,type=Int]
+-output_attributes=
+-AttributeReference[id=3,name=z,relation=a,type=Int]
==
SELECT a.z
FROM a JOIN b ON (a.w = b.w OR a.x > b.x)
JOIN c ON (a.x = c.x AND a.y > c.y)
JOIN d ON (a.y = d.y OR a.z > d.z);
--
TopLevelPlan
+-plan=NestedLoopsJoin
| +-left=HashJoin
| | +-left=NestedLoopsJoin
| | | +-left=TableReference[relation=a]
| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
| | | +-right=TableReference[relation=b]
| | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
| | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
| | | +-join_predicate=Or
| | | | +-Equal
| | | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
| | | | +-Greater
| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
| | | +-project_expressions=
| | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
| | +-right=TableReference[relation=c]
| | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
| | +-residual_predicate=Greater
| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
| | +-project_expressions=
| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
| | +-left_join_attributes=
| | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | +-right_join_attributes=
| | +-AttributeReference[id=6,name=x,relation=c,type=Int]
| +-right=TableReference[relation=d]
| | +-AttributeReference[id=8,name=y,relation=d,type=Int]
| | +-AttributeReference[id=9,name=z,relation=d,type=Int]
| +-join_predicate=Or
| | +-Equal
| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | +-AttributeReference[id=8,name=y,relation=d,type=Int]
| | +-Greater
| | +-AttributeReference[id=3,name=z,relation=a,type=Int]
| | +-AttributeReference[id=9,name=z,relation=d,type=Int]
| +-project_expressions=
| +-AttributeReference[id=3,name=z,relation=a,type=Int]
+-output_attributes=
+-AttributeReference[id=3,name=z,relation=a,type=Int]
==
SELECT a1.z
FROM a AS a1 JOIN b AS b1 ON a1.w = b1.w
JOIN c AS c1 ON a1.x = c1.x
JOIN d AS d1 ON a1.y = d1.y
WHERE a1.x = b1.x
AND a1.y = c1.y
AND a1.z = d1.z;
--
TopLevelPlan
+-plan=HashJoin
| +-left=HashJoin
| | +-left=HashJoin
| | | +-left=TableReference[relation=a,alias=a1]
| | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
| | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
| | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
| | | +-right=TableReference[relation=b,alias=b1]
| | | | +-AttributeReference[id=4,name=w,relation=b1,type=Int]
| | | | +-AttributeReference[id=5,name=x,relation=b1,type=Int]
| | | +-project_expressions=
| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
| | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
| | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
| | | +-left_join_attributes=
| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
| | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
| | | +-right_join_attributes=
| | | +-AttributeReference[id=5,name=x,relation=b1,type=Int]
| | | +-AttributeReference[id=4,name=w,relation=b1,type=Int]
| | +-right=TableReference[relation=c,alias=c1]
| | | +-AttributeReference[id=6,name=x,relation=c1,type=Int]
| | | +-AttributeReference[id=7,name=y,relation=c1,type=Int]
| | +-project_expressions=
| | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
| | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
| | +-left_join_attributes=
| | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
| | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
| | +-right_join_attributes=
| | +-AttributeReference[id=7,name=y,relation=c1,type=Int]
| | +-AttributeReference[id=6,name=x,relation=c1,type=Int]
| +-right=TableReference[relation=d,alias=d1]
| | +-AttributeReference[id=8,name=y,relation=d1,type=Int]
| | +-AttributeReference[id=9,name=z,relation=d1,type=Int]
| +-project_expressions=
| | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
| +-left_join_attributes=
| | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
| | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
| +-right_join_attributes=
| +-AttributeReference[id=9,name=z,relation=d1,type=Int]
| +-AttributeReference[id=8,name=y,relation=d1,type=Int]
+-output_attributes=
+-AttributeReference[id=3,name=z,relation=a1,type=Int]
==
SELECT a1.z
FROM a AS a1 JOIN b AS b1 ON a1.w <> b1.w
JOIN c AS c1 ON a1.x <> c1.x
JOIN d AS d1 ON a1.y <> d1.y
WHERE a1.x = b1.x
AND a1.y = c1.y
AND a1.z = d1.z;
--
TopLevelPlan
+-plan=HashJoin
| +-left=HashJoin
| | +-left=HashJoin
| | | +-left=TableReference[relation=a,alias=a1]
| | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
| | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
| | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
| | | +-right=TableReference[relation=b,alias=b1]
| | | | +-AttributeReference[id=4,name=w,relation=b1,type=Int]
| | | | +-AttributeReference[id=5,name=x,relation=b1,type=Int]
| | | +-residual_predicate=NotEqual
| | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
| | | | +-AttributeReference[id=4,name=w,relation=b1,type=Int]
| | | +-project_expressions=
| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
| | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
| | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
| | | +-left_join_attributes=
| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
| | | +-right_join_attributes=
| | | +-AttributeReference[id=5,name=x,relation=b1,type=Int]
| | +-right=TableReference[relation=c,alias=c1]
| | | +-AttributeReference[id=6,name=x,relation=c1,type=Int]
| | | +-AttributeReference[id=7,name=y,relation=c1,type=Int]
| | +-residual_predicate=NotEqual
| | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
| | | +-AttributeReference[id=6,name=x,relation=c1,type=Int]
| | +-project_expressions=
| | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
| | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
| | +-left_join_attributes=
| | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
| | +-right_join_attributes=
| | +-AttributeReference[id=7,name=y,relation=c1,type=Int]
| +-right=TableReference[relation=d,alias=d1]
| | +-AttributeReference[id=8,name=y,relation=d1,type=Int]
| | +-AttributeReference[id=9,name=z,relation=d1,type=Int]
| +-residual_predicate=NotEqual
| | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
| | +-AttributeReference[id=8,name=y,relation=d1,type=Int]
| +-project_expressions=
| | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
| +-left_join_attributes=
| | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
| +-right_join_attributes=
| +-AttributeReference[id=9,name=z,relation=d1,type=Int]
+-output_attributes=
+-AttributeReference[id=3,name=z,relation=a1,type=Int]
==
SELECT a.w, b.x, c.y, d.z
FROM a LEFT JOIN b ON a.w = b.w
LEFT JOIN c ON a.x = c.x
LEFT JOIN d ON a.y = d.y;
--
TopLevelPlan
+-plan=HashLeftOuterJoin
| +-left=HashLeftOuterJoin
| | +-left=HashLeftOuterJoin
| | | +-left=TableReference[relation=a]
| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
| | | +-right=TableReference[relation=b]
| | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
| | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
| | | +-project_expressions=
| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | | +-AttributeReference[id=5,name=x,relation=b,type=Int NULL]
| | | +-left_join_attributes=
| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | | +-right_join_attributes=
| | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
| | +-right=TableReference[relation=c]
| | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
| | +-project_expressions=
| | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | +-AttributeReference[id=5,name=x,relation=b,type=Int NULL]
| | | +-AttributeReference[id=7,name=y,relation=c,type=Int NULL]
| | +-left_join_attributes=
| | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | +-right_join_attributes=
| | +-AttributeReference[id=6,name=x,relation=c,type=Int]
| +-right=TableReference[relation=d]
| | +-AttributeReference[id=8,name=y,relation=d,type=Int]
| | +-AttributeReference[id=9,name=z,relation=d,type=Int]
| +-project_expressions=
| | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | +-AttributeReference[id=5,name=x,relation=b,type=Int NULL]
| | +-AttributeReference[id=7,name=y,relation=c,type=Int NULL]
| | +-AttributeReference[id=9,name=z,relation=d,type=Int NULL]
| +-left_join_attributes=
| | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| +-right_join_attributes=
| +-AttributeReference[id=8,name=y,relation=d,type=Int]
+-output_attributes=
+-AttributeReference[id=0,name=w,relation=a,type=Int]
+-AttributeReference[id=5,name=x,relation=b,type=Int NULL]
+-AttributeReference[id=7,name=y,relation=c,type=Int NULL]
+-AttributeReference[id=9,name=z,relation=d,type=Int NULL]
==
SELECT a.w, b.x, c.y, d.z
FROM a RIGHT JOIN b ON a.w = b.w
JOIN c ON a.x = c.x
LEFT JOIN d ON a.y = d.y
WHERE b.x > 10
AND c.y > 20;
--
TopLevelPlan
+-plan=HashLeftOuterJoin
| +-left=HashJoin
| | +-left=HashLeftOuterJoin
| | | +-left=Selection
| | | | +-input=TableReference[relation=b]
| | | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
| | | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
| | | | +-filter_predicate=Greater
| | | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
| | | | | +-Literal[value=10,type=Int]
| | | | +-project_expressions=
| | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
| | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
| | | +-right=TableReference[relation=a]
| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
| | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
| | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
| | | +-project_expressions=
| | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int NULL]
| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int NULL]
| | | | +-AttributeReference[id=2,name=y,relation=a,type=Int NULL]
| | | +-left_join_attributes=
| | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
| | | +-right_join_attributes=
| | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
| | +-right=Selection
| | | +-input=TableReference[relation=c]
| | | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
| | | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
| | | +-filter_predicate=Greater
| | | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
| | | | +-Literal[value=20,type=Int]
| | | +-project_expressions=
| | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
| | +-project_expressions=
| | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
| | | +-AttributeReference[id=0,name=w,relation=a,type=Int NULL]
| | | +-AttributeReference[id=2,name=y,relation=a,type=Int NULL]
| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
| | +-left_join_attributes=
| | | +-AttributeReference[id=1,name=x,relation=a,type=Int NULL]
| | +-right_join_attributes=
| | +-AttributeReference[id=6,name=x,relation=c,type=Int]
| +-right=TableReference[relation=d]
| | +-AttributeReference[id=8,name=y,relation=d,type=Int]
| | +-AttributeReference[id=9,name=z,relation=d,type=Int]
| +-project_expressions=
| | +-AttributeReference[id=0,name=w,relation=a,type=Int NULL]
| | +-AttributeReference[id=5,name=x,relation=b,type=Int]
| | +-AttributeReference[id=7,name=y,relation=c,type=Int]
| | +-AttributeReference[id=9,name=z,relation=d,type=Int NULL]
| +-left_join_attributes=
| | +-AttributeReference[id=2,name=y,relation=a,type=Int NULL]
| +-right_join_attributes=
| +-AttributeReference[id=8,name=y,relation=d,type=Int]
+-output_attributes=
+-AttributeReference[id=0,name=w,relation=a,type=Int NULL]
+-AttributeReference[id=5,name=x,relation=b,type=Int]
+-AttributeReference[id=7,name=y,relation=c,type=Int]
+-AttributeReference[id=9,name=z,relation=d,type=Int NULL]
==
SELECT *
FROM b LEFT JOIN c ON (b.x = c.x AND c.x > 10);
--
TopLevelPlan
+-plan=HashLeftOuterJoin
| +-left=TableReference[relation=b]
| | +-AttributeReference[id=0,name=w,relation=b,type=Int]
| | +-AttributeReference[id=1,name=x,relation=b,type=Int]
| +-right=Selection
| | +-input=TableReference[relation=c]
| | | +-AttributeReference[id=2,name=x,relation=c,type=Int]
| | | +-AttributeReference[id=3,name=y,relation=c,type=Int]
| | +-filter_predicate=Greater
| | | +-AttributeReference[id=2,name=x,relation=c,type=Int]
| | | +-Literal[value=10,type=Int]
| | +-project_expressions=
| | +-AttributeReference[id=2,name=x,relation=c,type=Int]
| | +-AttributeReference[id=3,name=y,relation=c,type=Int]
| +-project_expressions=
| | +-AttributeReference[id=0,name=w,relation=b,type=Int]
| | +-AttributeReference[id=1,name=x,relation=b,type=Int]
| | +-AttributeReference[id=2,name=x,relation=c,type=Int NULL]
| | +-AttributeReference[id=3,name=y,relation=c,type=Int NULL]
| +-left_join_attributes=
| | +-AttributeReference[id=1,name=x,relation=b,type=Int]
| +-right_join_attributes=
| +-AttributeReference[id=2,name=x,relation=c,type=Int]
+-output_attributes=
+-AttributeReference[id=0,name=w,relation=b,type=Int]
+-AttributeReference[id=1,name=x,relation=b,type=Int]
+-AttributeReference[id=2,name=x,relation=c,type=Int NULL]
+-AttributeReference[id=3,name=y,relation=c,type=Int NULL]