Skip to content

Commit

Permalink
[SPARK-49017][SQL][TESTS][FOLLOW-UP] Add testing for CreateTableAs wi…
Browse files Browse the repository at this point in the history
…th parameters

### What changes were proposed in this pull request?
Addition of a test for `CreateTableAsSelect`.

### Why are the changes needed?
While looking through parameter marker support in statements it was noticed that CacheTableAsSelect actually should not work with parameter markers, but returns UNBOUND_SQL_PARAMETER. (https://issues.apache.org/jira/browse/SPARK-49398 ticket which should solve this issue). Because of this, I suggest adding additional test for `CreateTableAsSelect` to make sure all paths work as expected.

### Does this PR introduce _any_ user-facing change?
No, only tests added.

### How was this patch tested?
N/A

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes apache#47886 from mihailom-db/follow-up-parameters.

Authored-by: Mihailo Milosevic <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
  • Loading branch information
mihailom-db authored and MaxGekk committed Aug 27, 2024
1 parent eb79fc4 commit c106c77
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sql/core/src/test/scala/org/apache/spark/sql/ParametersSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,22 @@ class ParametersSuite extends QueryTest with SharedSparkSession with PlanTest {
}
}

test("SPARK-49017: bind named parameters with IDENTIFIER clause in create table as") {
withTable("testtab", "testtab1") {

sql("create table testtab (id int, name string)")
sql("insert into testtab values(1, 'test1')")

// create table with parameters in query
spark.sql(
"""create table identifier(:tab) as
| select * from testtab where identifier(:col) == 1""".stripMargin,
Map("tab" -> "testtab1", "col" -> "id"))

checkAnswer(sql("select * from testtab1"), Seq(Row(1, "test1")))
}
}

test("SPARK-46999: bind parameters for nested IDENTIFIER clause") {
val query = sql(
"""
Expand Down

0 comments on commit c106c77

Please sign in to comment.