Skip to content

Commit 37c898c

Browse files
committed
[MINOR][CONNECT][TESTS] Check named parameters in sql()
### What changes were proposed in this pull request? In the PR, I propose to add new tests to check named parameters in `sql()` of Scala connect client. ### Why are the changes needed? To improve test coverage. Before the PR, the feature has not been tested at all. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? By running new test: ``` $ build/sbt -Phive-2.3 -Phive-thriftserver "test:testOnly *.ClientE2ETestSuite" ``` Closes apache#41726 from MaxGekk/test-named-params-proto. Authored-by: Max Gekk <[email protected]> Signed-off-by: Max Gekk <[email protected]>
1 parent 646388e commit 37c898c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/ClientE2ETestSuite.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,17 @@ class ClientE2ETestSuite extends RemoteSparkSession with SQLHelper with PrivateM
960960
assert(result2(0).getInt(0) === 1)
961961
assert(result2(0).getString(1) === "abc")
962962
}
963+
964+
test("sql() with named parameters") {
965+
val result0 = spark.sql("select 1", Map.empty[String, Any]).collect()
966+
assert(result0.length == 1 && result0(0).getInt(0) === 1)
967+
968+
val result1 = spark.sql("select :abc", Map("abc" -> 1)).collect()
969+
assert(result1.length == 1 && result1(0).getInt(0) === 1)
970+
971+
val result2 = spark.sql("select :c0 limit :l0", Map("l0" -> 1, "c0" -> "abc")).collect()
972+
assert(result2.length == 1 && result2(0).getString(0) === "abc")
973+
}
963974
}
964975

965976
private[sql] case class MyType(id: Long, a: Double, b: Double)

0 commit comments

Comments
 (0)