Skip to content

Commit

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

val testTable = "test_substring_index"
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)))
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)))
}
}
}

Expand Down

0 comments on commit 2f54c99

Please sign in to comment.