Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve the test
  • Loading branch information
MaxGekk committed Nov 14, 2024
commit 3b991d126b09f73a9c747bd3ef7b74ccdcd2b2dc
19 changes: 11 additions & 8 deletions sql/core/src/test/scala/org/apache/spark/sql/ParametersSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -742,17 +742,20 @@ class ParametersSuite extends QueryTest with SharedSparkSession with PlanTest {
}
}

test("parameterized identifier in a sub-query") {
test("SPARK-50322: parameterized identifier in a sub-query") {
withTable("tt1") {
sql("create table tt1(c1 int)")
sql("insert into tt1 values (1)")
val df = spark.sql("""
|with v1 as (
| select * from tt1
| where 1 = (Select * from identifier(:tab))
|) select * from v1""".stripMargin,
args = Map("tab" -> "tt1"))
checkAnswer(df, Row(1))
def query(p: String): String = {
s"""
|with v1 as (
| select * from tt1
| where 1 = (Select * from identifier($p))
|) select * from v1""".stripMargin
}

checkAnswer(spark.sql(query(":tab"), args = Map("tab" -> "tt1")), Row(1))
checkAnswer(spark.sql(query("?"), args = Array("tt1")), Row(1))
}
}
}