KNN 조인
| 항목 | 값 |
|---|---|
| 화면 이름 | KNN join |
| 식별자 | complexKnnJoinV1 |
| 지원 실행 방식 | Batch |
| 범주 | 조인 (Join) |
왼쪽의 각 행에 대해 거리 척도상 가장 가까운 오른쪽 행 k개를 반환합니다.
입력 인자
| 이름 | 지정 여부 | 자료형 | 의미와 조건 |
|---|---|---|---|
Condition for columns to select on the left | 필수 | ColumnPredicate | 왼쪽 스키마의 각 열을 검사하여 조건에 맞는 열만 출력으로 선택합니다. |
Condition for columns to select on the right | 필수 | ColumnPredicate | 오른쪽 스키마의 각 열을 검사하여 조건에 맞는 열만 출력으로 선택합니다. |
Distance measure expression | 필수 | Expression<Numeric> | 양쪽 데이터셋의 열 사이 거리를 계산할 표현식입니다. 예를 들어 Levenshtein 거리를 사용할 수 있습니다. |
K nearest | 필수 | Literal<Integer> | 반환할 가장 가까운 행 수입니다. k=2이면 오른쪽의 두 행을 조인하여 출력 행 수가 적어도 두 배가 됩니다. 동점이 있으면 더 많은 행을 반환할 수 있습니다. |
Left dataset | 필수 | Table | 조인에 사용할 왼쪽 데이터셋입니다. |
Rank column name | 필수 | Literal<String> | 거리 순위를 기록할 열 이름입니다. |
Right dataset | 필수 | Table | 조인에 사용할 오른쪽 데이터셋입니다. |
Prefix for columns from right | 선택 | Literal<String> | 오른쪽의 모든 열에 붙일 접두사입니다. |
입출력 예시
예시 1: 기본 동작
인자 값:
Condition for columns to select on the left:
columnNameIsIn(
columnNames: [tail_number, airline],
)Condition for columns to select on the right:
columnNameIsIn(
columnNames: [fuzzy_airline, home_airport],
)Distance measure expression:
alias(
alias: distance,
expression:
levenshteinDistance(
ignoreCase: true,
left:airline,
right:fuzzy_airline,
),
)K nearest: 2Left dataset: ri.foundry.main.dataset.leftRank column name: rankRight dataset: ri.foundry.main.dataset.rightPrefix for columns from right: null
입력:
ri.foundry.main.dataset.left
| tail_number | airline | miles | factor |
|---|---|---|---|
| XB-123 | foundry air | 124 | 2 |
| MT-222 | new airline | 1123 | 5 |
| PA-452 | new air | 212 | 2 |
ri.foundry.main.dataset.right
| fuzzy_airline | home_airport |
|---|---|
| air | LHR |
| new airline | CPH |
| new plane | JFK |
| old air | IAD |
출력:
| rank | distance | tail_number | airline | fuzzy_airline | home_airport |
|---|---|---|---|---|---|
| 1 | 3 | PA-452 | new air | old air | IAD |
| 2 | 4 | PA-452 | new air | air | LHR |
| 2 | 4 | PA-452 | new air | new airline | CPH |
| 2 | 4 | PA-452 | new air | new plane | JFK |
| 1 | 0 | MT-222 | new airline | new airline | CPH |
| 2 | 4 | MT-222 | new airline | new plane | JFK |
| 1 | 5 | XB-123 | foundry air | old air | IAD |
| 2 | 8 | XB-123 | foundry air | air | LHR |
예시 2: 기본 동작
인자 값:
Condition for columns to select on the left:
columnNameIsIn(
columnNames: [tail_number, airline],
)Condition for columns to select on the right:
columnNameIsIn(
columnNames: [home_airport],
)Distance measure expression:
alias(
alias: distance,
expression:
levenshteinDistance(
ignoreCase: true,
left:airline,
right:airline,
),
)K nearest: 2Left dataset: ri.foundry.main.dataset.leftRank column name: rankRight dataset: ri.foundry.main.dataset.rightPrefix for columns from right: null
입력:
ri.foundry.main.dataset.left
| tail_number | airline | miles | factor |
|---|---|---|---|
| XB-123 | foundry air | 124 | 2 |
| MT-222 | new airline | 1123 | 5 |
| PA-452 | new air | 212 | 2 |
ri.foundry.main.dataset.right
| airline | home_airport |
|---|---|
| air | LHR |
| new airline | CPH |
| new plane | JFK |
| old air | IAD |
출력:
| rank | distance | tail_number | airline | home_airport |
|---|---|---|---|---|
| 1 | 3 | PA-452 | new air | IAD |
| 2 | 4 | PA-452 | new air | LHR |
| 2 | 4 | PA-452 | new air | CPH |
| 2 | 4 | PA-452 | new air | JFK |
| 1 | 0 | MT-222 | new airline | CPH |
| 2 | 4 | MT-222 | new airline | JFK |
| 1 | 5 | XB-123 | foundry air | IAD |
| 2 | 8 | XB-123 | foundry air | LHR |
예시 3: 기본 동작
거리 표현식이 null을 반환하면 가장 먼 거리로 취급합니다.
인자 값:
Condition for columns to select on the left:
columnNameIsIn(
columnNames: [tail_number, airline],
)Condition for columns to select on the right:
columnNameIsIn(
columnNames: [fuzzy_airline, home_airport],
)Distance measure expression:
alias(
alias: distance,
expression:
levenshteinDistance(
ignoreCase: true,
left:airline,
right:fuzzy_airline,
),
)K nearest: 2Left dataset: ri.foundry.main.dataset.leftRank column name: rankRight dataset: ri.foundry.main.dataset.rightPrefix for columns from right: null
입력:
ri.foundry.main.dataset.left
| tail_number | airline | miles | factor |
|---|---|---|---|
| XB-123 | foundry air | 124 | 2 |
| MT-222 | new airline | 1123 | 5 |
| PA-452 | new air | 212 | 2 |
ri.foundry.main.dataset.right
| fuzzy_airline | home_airport |
|---|---|
| air | LHR |
| null | CPH |
| new plane | JFK |
| old air | IAD |
출력:
| rank | distance | tail_number | airline | fuzzy_airline | home_airport |
|---|---|---|---|---|---|
| 1 | 3 | PA-452 | new air | old air | IAD |
| 2 | 4 | PA-452 | new air | air | LHR |
| 2 | 4 | PA-452 | new air | new plane | JFK |
| 1 | 4 | MT-222 | new airline | new plane | JFK |
| 2 | 7 | MT-222 | new airline | old air | IAD |
| 1 | 5 | XB-123 | foundry air | old air | IAD |
| 2 | 8 | XB-123 | foundry air | air | LHR |
예시 4: 기본 동작
인자 값:
Condition for columns to select on the left:
columnNameIsIn(
columnNames: [tail_number, airline],
)Condition for columns to select on the right:
columnNameIsIn(
columnNames: [fuzzy_airline, home_airport],
)Distance measure expression:
alias(
alias: distance,
expression:
levenshteinDistance(
ignoreCase: true,
left:airline,
right:fuzzy_airline,
),
)K nearest: 2Left dataset: ri.foundry.main.dataset.leftRank column name: rankRight dataset: ri.foundry.main.dataset.rightPrefix for columns from right: right_
입력:
ri.foundry.main.dataset.left
| tail_number | airline | miles | factor |
|---|---|---|---|
| XB-123 | foundry air | 124 | 2 |
| MT-222 | new airline | 1123 | 5 |
| PA-452 | new air | 212 | 2 |
ri.foundry.main.dataset.right
| fuzzy_airline | home_airport |
|---|---|
| air | LHR |
| new airline | CPH |
| new plane | JFK |
| old air | IAD |
출력:
| rank | distance | tail_number | airline | right_fuzzy_airline | right_home_airport |
|---|---|---|---|---|---|
| 1 | 3 | PA-452 | new air | old air | IAD |
| 2 | 4 | PA-452 | new air | air | LHR |
| 2 | 4 | PA-452 | new air | new airline | CPH |
| 2 | 4 | PA-452 | new air | new plane | JFK |
| 1 | 0 | MT-222 | new airline | new airline | CPH |
| 2 | 4 | MT-222 | new airline | new plane | JFK |
| 1 | 5 | XB-123 | foundry air | old air | IAD |
| 2 | 8 | XB-123 | foundry air | air | LHR |