Skip to content

Commit f264a62

Browse files
committed
add more golden explain plan tests
1 parent e2e5c9e commit f264a62

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

pinot-query-planner/src/test/resources/queries/PhysicalOptimizerPlans.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,76 @@
11251125
"\n PhysicalTableScan(table=[[default, a]])",
11261126
"\n"
11271127
]
1128+
},
1129+
{
1130+
"description": "Two lookup joins on different dimension tables in one query",
1131+
"sql": "SET usePhysicalOptimizer=true; EXPLAIN PLAN FOR SELECT /*+ joinOptions(join_strategy='lookup') */ a.col1, b.col2, c.col2 FROM a JOIN b ON a.col1 = b.col1 JOIN c ON a.col2 = c.col1",
1132+
"output": [
1133+
"Execution Plan",
1134+
"\nPhysicalExchange(exchangeStrategy=[SINGLETON_EXCHANGE])",
1135+
"\n PhysicalProject(col1=[$0], col2=[$3], col20=[$5])",
1136+
"\n PhysicalExchange(exchangeStrategy=[IDENTITY_EXCHANGE])",
1137+
"\n PhysicalJoin(condition=[=($1, $4)], joinType=[inner])",
1138+
"\n PhysicalExchange(exchangeStrategy=[IDENTITY_EXCHANGE])",
1139+
"\n PhysicalJoin(condition=[=($0, $2)], joinType=[inner])",
1140+
"\n PhysicalExchange(exchangeStrategy=[IDENTITY_EXCHANGE])",
1141+
"\n PhysicalProject(col1=[$0], col2=[$1])",
1142+
"\n PhysicalTableScan(table=[[default, a]])",
1143+
"\n PhysicalExchange(exchangeStrategy=[LOOKUP_LOCAL_EXCHANGE])",
1144+
"\n PhysicalProject(col1=[$0], col2=[$1])",
1145+
"\n PhysicalTableScan(table=[[default, b]])",
1146+
"\n PhysicalExchange(exchangeStrategy=[LOOKUP_LOCAL_EXCHANGE])",
1147+
"\n PhysicalProject(col1=[$0], col2=[$1])",
1148+
"\n PhysicalTableScan(table=[[default, c]])",
1149+
"\n"
1150+
]
1151+
},
1152+
{
1153+
"description": "Hash join then lookup join on same table with aggregation",
1154+
"sql": "SET usePhysicalOptimizer=true; EXPLAIN PLAN FOR SELECT /*+ joinOptions(join_strategy='lookup') */ t.col1, SUM(t.col3) FROM (SELECT /*+ joinOptions(join_strategy='hash') */ a.col1, a.col3, b.col2 AS dim1 FROM a JOIN b ON a.col2 = b.col1) t JOIN b dim2 ON t.col1 = dim2.col1 GROUP BY t.col1",
1155+
"output": [
1156+
"Execution Plan",
1157+
"\nPhysicalExchange(exchangeStrategy=[SINGLETON_EXCHANGE])",
1158+
"\n PhysicalAggregate(group=[{0}], agg#0=[$SUM0($1)], aggType=[FINAL])",
1159+
"\n PhysicalExchange(exchangeStrategy=[PARTITIONING_EXCHANGE], distKeys=[[0]])",
1160+
"\n PhysicalAggregate(group=[{0}], agg#0=[$SUM0($1)], aggType=[LEAF])",
1161+
"\n PhysicalExchange(exchangeStrategy=[IDENTITY_EXCHANGE])",
1162+
"\n PhysicalJoin(condition=[=($0, $2)], joinType=[inner])",
1163+
"\n PhysicalExchange(exchangeStrategy=[IDENTITY_EXCHANGE])",
1164+
"\n PhysicalProject(col1=[$0], col3=[$2])",
1165+
"\n PhysicalJoin(condition=[=($1, $3)], joinType=[inner])",
1166+
"\n PhysicalExchange(exchangeStrategy=[IDENTITY_EXCHANGE])",
1167+
"\n PhysicalProject(col1=[$0], col2=[$1], col3=[$2])",
1168+
"\n PhysicalTableScan(table=[[default, a]])",
1169+
"\n PhysicalExchange(exchangeStrategy=[PARTITIONING_EXCHANGE], distKeys=[[0]])",
1170+
"\n PhysicalProject(col1=[$0])",
1171+
"\n PhysicalTableScan(table=[[default, b]])",
1172+
"\n PhysicalExchange(exchangeStrategy=[LOOKUP_LOCAL_EXCHANGE])",
1173+
"\n PhysicalProject(col1=[$0])",
1174+
"\n PhysicalTableScan(table=[[default, b]])",
1175+
"\n"
1176+
]
1177+
},
1178+
{
1179+
"description": "Window function feeding into lookup join",
1180+
"sql": "SET usePhysicalOptimizer=true; EXPLAIN PLAN FOR SELECT /*+ joinOptions(join_strategy='lookup') */ t.col1, t.running_total, b.col2 FROM (SELECT col1, col2, SUM(col3) OVER (PARTITION BY col1 ORDER BY col2) AS running_total FROM a) t JOIN b ON t.col1 = b.col1",
1181+
"output": [
1182+
"Execution Plan",
1183+
"\nPhysicalExchange(exchangeStrategy=[SINGLETON_EXCHANGE])",
1184+
"\n PhysicalProject(col1=[$0], running_total=[$1], col2=[$3])",
1185+
"\n PhysicalExchange(exchangeStrategy=[IDENTITY_EXCHANGE])",
1186+
"\n PhysicalJoin(condition=[=($0, $2)], joinType=[inner])",
1187+
"\n PhysicalExchange(exchangeStrategy=[IDENTITY_EXCHANGE])",
1188+
"\n PhysicalProject(col1=[$0], $1=[$3])",
1189+
"\n PhysicalWindow(window#0=[window(partition {0} order by [1] aggs [SUM($2)])])",
1190+
"\n PhysicalExchange(exchangeStrategy=[PARTITIONING_EXCHANGE], distKeys=[[0]], collation=[[1]])",
1191+
"\n PhysicalProject(col1=[$0], col2=[$1], col3=[$2])",
1192+
"\n PhysicalTableScan(table=[[default, a]])",
1193+
"\n PhysicalExchange(exchangeStrategy=[LOOKUP_LOCAL_EXCHANGE])",
1194+
"\n PhysicalProject(col1=[$0], col2=[$1])",
1195+
"\n PhysicalTableScan(table=[[default, b]])",
1196+
"\n"
1197+
]
11281198
}
11291199
]
11301200
}

0 commit comments

Comments
 (0)