Skip to content

Commit

Permalink
[SPARK-25121][SQL][FOLLOWUP] Add more unit tests for multi-part ident…
Browse files Browse the repository at this point in the history
…ifiers in join strategy hints

### What changes were proposed in this pull request?

This pr intends to add unit tests for the other join hints (`MERGEJOIN`, `SHUFFLE_HASH`, and `SHUFFLE_REPLICATE_NL`). This is a followup PR of #27935.

### Why are the changes needed?

For better test coverage.

### Does this PR introduce any user-facing change?

No.

### How was this patch tested?

Added unit tests.

Closes #28013 from maropu/SPARK-25121-FOLLOWUP.

Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit da49f50)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
  • Loading branch information
maropu authored and dongjoon-hyun committed Mar 25, 2020
1 parent bd99994 commit e6c85b3
Showing 1 changed file with 49 additions and 44 deletions.
Expand Up @@ -242,51 +242,56 @@ class ResolveHintsSuite extends AnalysisTest {
caseSensitive = false)
}

test("Supports multi-part table names for broadcast hint resolution") {
// local temp table (single-part identifier case)
checkAnalysis(
UnresolvedHint("MAPJOIN", Seq("table", "table2"),
table("TaBlE").join(table("TaBlE2"))),
Join(
ResolvedHint(testRelation, HintInfo(strategy = Some(BROADCAST))),
ResolvedHint(testRelation2, HintInfo(strategy = Some(BROADCAST))),
Inner,
None,
JoinHint.NONE),
caseSensitive = false)

checkAnalysis(
UnresolvedHint("MAPJOIN", Seq("TaBlE", "table2"),
table("TaBlE").join(table("TaBlE2"))),
Join(
ResolvedHint(testRelation, HintInfo(strategy = Some(BROADCAST))),
testRelation2,
Inner,
None,
JoinHint.NONE),
caseSensitive = true)
test("Supports multi-part table names for join strategy hint resolution") {
Seq(("MAPJOIN", BROADCAST),
("MERGEJOIN", SHUFFLE_MERGE),
("SHUFFLE_HASH", SHUFFLE_HASH),
("SHUFFLE_REPLICATE_NL", SHUFFLE_REPLICATE_NL)).foreach { case (hintName, st) =>
// local temp table (single-part identifier case)
checkAnalysis(
UnresolvedHint(hintName, Seq("table", "table2"),
table("TaBlE").join(table("TaBlE2"))),
Join(
ResolvedHint(testRelation, HintInfo(strategy = Some(st))),
ResolvedHint(testRelation2, HintInfo(strategy = Some(st))),
Inner,
None,
JoinHint.NONE),
caseSensitive = false)

// global temp table (multi-part identifier case)
checkAnalysis(
UnresolvedHint("MAPJOIN", Seq("GlOBal_TeMP.table4", "table5"),
table("global_temp", "table4").join(table("global_temp", "table5"))),
Join(
ResolvedHint(testRelation4, HintInfo(strategy = Some(BROADCAST))),
ResolvedHint(testRelation5, HintInfo(strategy = Some(BROADCAST))),
Inner,
None,
JoinHint.NONE),
caseSensitive = false)
checkAnalysis(
UnresolvedHint(hintName, Seq("TaBlE", "table2"),
table("TaBlE").join(table("TaBlE2"))),
Join(
ResolvedHint(testRelation, HintInfo(strategy = Some(st))),
testRelation2,
Inner,
None,
JoinHint.NONE),
caseSensitive = true)

// global temp table (multi-part identifier case)
checkAnalysis(
UnresolvedHint(hintName, Seq("GlOBal_TeMP.table4", "table5"),
table("global_temp", "table4").join(table("global_temp", "table5"))),
Join(
ResolvedHint(testRelation4, HintInfo(strategy = Some(st))),
ResolvedHint(testRelation5, HintInfo(strategy = Some(st))),
Inner,
None,
JoinHint.NONE),
caseSensitive = false)

checkAnalysis(
UnresolvedHint("MAPJOIN", Seq("global_temp.TaBlE4", "table5"),
table("global_temp", "TaBlE4").join(table("global_temp", "TaBlE5"))),
Join(
ResolvedHint(testRelation4, HintInfo(strategy = Some(BROADCAST))),
testRelation5,
Inner,
None,
JoinHint.NONE),
caseSensitive = true)
checkAnalysis(
UnresolvedHint(hintName, Seq("global_temp.TaBlE4", "table5"),
table("global_temp", "TaBlE4").join(table("global_temp", "TaBlE5"))),
Join(
ResolvedHint(testRelation4, HintInfo(strategy = Some(st))),
testRelation5,
Inner,
None,
JoinHint.NONE),
caseSensitive = true)
}
}
}

0 comments on commit e6c85b3

Please sign in to comment.