Skip to content

Commit

Permalink
add more test
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneguow committed Jul 26, 2024
1 parent 2f54c99 commit 5fb5e62
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ 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}'")
Expand All @@ -434,6 +435,18 @@ class StringFunctionsSuite extends QueryTest with SharedSparkSession {
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)))
}
}
}

test("string locate function") {
Expand Down

0 comments on commit 5fb5e62

Please sign in to comment.