MaxGekk commented on code in PR #49232:
URL: https://github.com/apache/spark/pull/49232#discussion_r1892480289
##########
sql/core/src/test/scala/org/apache/spark/sql/ParametersSuite.scala:
##########
@@ -769,4 +769,40 @@ class ParametersSuite extends QueryTest with
SharedSparkSession with PlanTest {
checkAnswer(spark.sql(query(":cte"), args = Map("cte" -> "t1")), Row(1))
checkAnswer(spark.sql(query("?"), args = Array("t1")), Row(1))
}
+
+ test("SPARK-24497: parameterized identifier referencing a recursive CTE") {
+ def query(p: String): String = {
+ s"""
+ |WITH t1(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM t1 WHERE n<5)
+ |SELECT * FROM IDENTIFIER($p)""".stripMargin
Review Comment:
```suggestion
|WITH t1(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM t1 WHERE n<5)
|SELECT * FROM IDENTIFIER($p)""".stripMargin
```
##########
sql/core/src/test/scala/org/apache/spark/sql/ParametersSuite.scala:
##########
@@ -769,4 +769,40 @@ class ParametersSuite extends QueryTest with
SharedSparkSession with PlanTest {
checkAnswer(spark.sql(query(":cte"), args = Map("cte" -> "t1")), Row(1))
checkAnswer(spark.sql(query("?"), args = Array("t1")), Row(1))
}
+
+ test("SPARK-24497: parameterized identifier referencing a recursive CTE") {
+ def query(p: String): String = {
+ s"""
+ |WITH t1(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM t1 WHERE n<5)
+ |SELECT * FROM IDENTIFIER($p)""".stripMargin
+ }
+
+ // checkAnswer(spark.sql(query(":cte"), args = Map("cte" -> "t1")),
+ // Seq(Row(1), Row(2), Row(3), Row(4), Row(5)))
+ // checkAnswer(spark.sql(query("?"), args = Array("t1")),
+ // Seq(Row(1), Row(2), Row(3), Row(4), Row(5)))
+
+ checkError(
+ exception = intercept[AnalysisException] {
+ spark.sql(query(":cte"), args = Map("cte" -> "t1")).show()
Review Comment:
please, avoid `.show()` in tests
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]