You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "MaxGekk (via GitHub)" <gi...@apache.org> on 2023/06/15 15:55:19 UTC
[GitHub] [spark] MaxGekk commented on a diff in pull request #41568: [SPARK-44066][SQL] Support positional parameters in Scala/Java `sql()`
MaxGekk commented on code in PR #41568:
URL: https://github.com/apache/spark/pull/41568#discussion_r1231227948
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala:
##########
@@ -1360,22 +1360,40 @@ class AnalysisSuite extends AnalysisTest with Matchers {
test("SPARK-41271: bind named parameters to literals") {
CTERelationDef.curId.set(0)
- val actual1 = ParameterizedQuery(
+ val actual1 = NameParameterizedQuery(
child = parsePlan("WITH a AS (SELECT 1 c) SELECT * FROM a LIMIT :limitA"),
args = Map("limitA" -> Literal(10))).analyze
CTERelationDef.curId.set(0)
val expected1 = parsePlan("WITH a AS (SELECT 1 c) SELECT * FROM a LIMIT 10").analyze
comparePlans(actual1, expected1)
// Ignore unused arguments
CTERelationDef.curId.set(0)
- val actual2 = ParameterizedQuery(
+ val actual2 = NameParameterizedQuery(
child = parsePlan("WITH a AS (SELECT 1 c) SELECT c FROM a WHERE c < :param2"),
args = Map("param1" -> Literal(10), "param2" -> Literal(20))).analyze
CTERelationDef.curId.set(0)
val expected2 = parsePlan("WITH a AS (SELECT 1 c) SELECT c FROM a WHERE c < 20").analyze
comparePlans(actual2, expected2)
}
+ test("SPARK-44066: bind positional parameters to literals") {
+ CTERelationDef.curId.set(0)
+ val actual1 = PosParameterizedQuery(
+ child = parsePlan("WITH a AS (SELECT 1 c) SELECT * FROM a LIMIT ?"),
+ args = Seq(Literal(10))).analyze
+ CTERelationDef.curId.set(0)
+ val expected1 = parsePlan("WITH a AS (SELECT 1 c) SELECT * FROM a LIMIT 10").analyze
+ comparePlans(actual1, expected1)
+ // Ignore unused arguments
Review Comment:
> Error out when there are less number of arguments than positional placeholders (?)
Such test has been added already, see `test("non-substituted positional parameters")` in `ParametersSuite`, please.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org