Skip to content

Commit c137b75

Browse files
authored
Add query test cases for LOOKUP join (#18279)
1 parent 85cdc7c commit c137b75

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

pinot-query-planner/src/main/java/org/apache/pinot/query/routing/WorkerManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ private void assignWorkersToNonRootFragment(PlanFragment fragment, DispatchableP
149149
metadata.setWorkerIdToServerInstanceMap(workerIdToServerInstanceMap);
150150
metadata.setPartitionFunction(childMetadata.getPartitionFunction());
151151
// Fake a segments map so that the worker can be correctly identified as leaf stage
152-
// TODO: Add a query test for LOOKUP join
153152
Map<String, List<String>> segmentsMap = Map.of(TableType.OFFLINE.name(), List.of());
154153
Map<Integer, Map<String, List<String>>> workerIdToSegmentsMap =
155154
Maps.newHashMapWithExpectedSize(workerIdToServerInstanceMap.size());

pinot-query-runtime/src/test/resources/queries/LookupJoin.json

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lookup_join_basic": {
3-
"comment": "Tests lookup join with a dimension table. V1 and V2 pass end-to-end. Lite mode is skipped because the broker lacks DimensionTableDataManager. The V2 path is additionally validated at the planner level by LookupJoinPlanTest.",
3+
"comment": "Tests lookup join with a dimension table: inner/left join, fact-side filter, and aggregation above the join. V1 and V2 pass end-to-end. Lite mode is skipped because the broker lacks DimensionTableDataManager. The V2 path is additionally validated at the planner level by LookupJoinPlanTest. Exercises WorkerManager.assignWorkersToNonRootFragment lookup-join branch on the V1 path.",
44
"tables": {
55
"fact_tbl": {
66
"schema": [
@@ -41,6 +41,38 @@
4141
[3, "gamma"]
4242
],
4343
"ignoreLiteMode": true
44+
},
45+
{
46+
"description": "Left outer lookup join - unmatched fact row (dim_key=4) preserved with null dim column",
47+
"sql": "SELECT /*+ joinOptions(join_strategy='lookup') */ {fact_tbl}.dim_key, {dim_tbl}.name FROM {fact_tbl} LEFT JOIN {dim_tbl} ON {fact_tbl}.dim_key = {dim_tbl}.id",
48+
"outputs": [
49+
[1, "alpha"],
50+
[1, "alpha"],
51+
[2, "beta"],
52+
[3, "gamma"],
53+
[4, null]
54+
],
55+
"ignoreLiteMode": true
56+
},
57+
{
58+
"description": "Lookup join with filter on fact-side column - filter applied before the join",
59+
"sql": "SELECT /*+ joinOptions(join_strategy='lookup') */ {fact_tbl}.dim_key, {fact_tbl}.metric, {dim_tbl}.name FROM {fact_tbl} JOIN {dim_tbl} ON {fact_tbl}.dim_key = {dim_tbl}.id WHERE {fact_tbl}.metric >= 200",
60+
"outputs": [
61+
[2, 200, "beta"],
62+
[3, 300, "gamma"],
63+
[1, 400, "alpha"]
64+
],
65+
"ignoreLiteMode": true
66+
},
67+
{
68+
"description": "Aggregation above lookup join - counts matched fact rows per dim name",
69+
"sql": "SELECT /*+ joinOptions(join_strategy='lookup') */ {dim_tbl}.name, COUNT(*) FROM {fact_tbl} JOIN {dim_tbl} ON {fact_tbl}.dim_key = {dim_tbl}.id GROUP BY {dim_tbl}.name",
70+
"outputs": [
71+
["alpha", 2],
72+
["beta", 1],
73+
["gamma", 1]
74+
],
75+
"ignoreLiteMode": true
4476
}
4577
]
4678
}

0 commit comments

Comments
 (0)