Skip to content

Commit

Permalink
update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneguow committed Jul 29, 2024
1 parent 5fb5e62 commit 2941b31
Showing 1 changed file with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,26 +426,11 @@ class StringFunctionsSuite extends QueryTest with SharedSparkSession {
)

val testTable = "test_substring_index"
// count is int
withTempPath { path =>
withTable(testTable) {
sql(s"CREATE TABLE $testTable (num int) USING parquet LOCATION '${path.toURI.toString}'")
sql(s"INSERT INTO $testTable VALUES (1), (2), (3), (NULL)")
val query = s"SELECT num, SUBSTRING_INDEX('a_a_a', '_', num) as sub_str FROM $testTable"
checkAnswer(sql(query), Seq(Row(1, "a"), Row(2, "a_a"), Row(3, "a_a_a"), Row(null, null)))
}
}
// count is string
withTempPath { path =>
withTable(testTable) {
sql(s"CREATE TABLE $testTable (num string) USING parquet " +
s"LOCATION '${path.toURI.toString}'")
sql(s"INSERT INTO $testTable VALUES ('1'), ('2'), ('3'), (NULL)")
val query = s"SELECT num, SUBSTRING_INDEX('a_a_a', '_', num) as sub_str FROM $testTable"
checkAnswer(
sql(query),
Seq(Row("1", "a"), Row("2", "a_a"), Row("3", "a_a_a"), Row(null, null)))
}
withTable(testTable) {
sql(s"CREATE TABLE $testTable (num int) USING parquet")
sql(s"INSERT INTO $testTable VALUES (1), (2), (3), (NULL)")
val query = s"SELECT num, SUBSTRING_INDEX('a_a_a', '_', num) as sub_str FROM $testTable"
checkAnswer(sql(query), Seq(Row(1, "a"), Row(2, "a_a"), Row(3, "a_a_a"), Row(null, null)))
}
}

Expand Down

0 comments on commit 2941b31

Please sign in to comment.