The Lookup UDF Join is only supported with the single-stage query engine (v1). For more information about using JOINs with the multi-stage query engine, see JOINs.
Lookup UDF is used to get dimension data via primary key from a dimension table allowing a decoration join functionality. Lookup UDF can only be used with a dimension table in Pinot.
The UDF function syntax is listed as below:
dimTable
Name of the dim table to perform the lookup on.dimColToLookUp
The column name of the dim table to be retrieved to decorate our result.dimJoinKey
The column name on which we want to perform the lookup i.e. the join column name for dim table.factJoinKey
The column name on which we want to perform the lookup against e.g. the join column name for fact tableactTable
table.[ '''dimJoinKey''', factJoinKey ]*
indicates that if there are multiple dim partition columns, there should be multiple join key pair expressed.Consider the table baseballStats
Column | Type |
---|---|
playerID | STRING |
yearID | INT |
teamID | STRING |
league | STRING |
playerName | STRING |
playerStint | INT |
numberOfGames | INT |
numberOfGamesAsBatter | INT |
AtBatting | INT |
runs | INT |
And the dim table dimBaseballTeams
Column | Type |
---|---|
teamID | STRING |
teamName | STRING |
teamAddress | STRING |
Valid queries include the following:
playerName | teamID | teamName | teamAddress |
---|---|---|---|
David Allan | BOS | Boston Red Caps/Beaneaters (from 1876–1900) or Boston Red Sox (since 1953) | 4 Jersey Street, Boston, MA |
David Allan | CHA | null | null |
David Allan | SEA | Seattle Mariners (since 1977) or Seattle Pilots (1969) | 1250 First Avenue South, Seattle, WA |
David Allan | SEA | Seattle Mariners (since 1977) or Seattle Pilots (1969) | 1250 First Avenue South, Seattle, WA |
teamID | nameFromLocal | nameFromLookup |
---|---|---|
ANA | Anaheim Angels | Anaheim Angels |
ARI | Arizona Diamondbacks | Arizona Diamondbacks |
ATL | Atlanta Braves | Atlanta Braves |
BAL | Baltimore Orioles (original- 1901–1902 current- since 1954) | Baltimore Orioles (original- 1901–1902 current- since 1954) |
Consider a single dimension table with the following schema:
BILLING SCHEMA
Column | Type |
---|---|
customerId | INT |
creditHistory | STRING |
firstName | STRING |
lastName | STRING |
isCarOwner | BOOLEAN |
city | STRING |
maritalStatus | STRING |
buildingType | STRING |
missedPayment | STRING |
billingMonth | STRING |
customerId | missedPayment | lookedupCity |
---|---|---|
341 | Paid | Palo Alto |
374 | Paid | Mountain View |
398 | Paid | Palo Alto |
427 | Paid | Cupertino |
435 | Paid | Cupertino |
dimColToLookUp
column type.primaryKeyColumns
from the dimension table schema.