This is an automated email from the ASF dual-hosted git repository.
uros-b pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-4.x by this push:
new 6020f4f8cd56 [SPARK-60197][SQL][TEST] Add DROP TABLE SQL golden tests
6020f4f8cd56 is described below
commit 6020f4f8cd565988e8306a9e05fcc9ab6031d6ba
Author: Vladan Vasić <[email protected]>
AuthorDate: Thu Oct 22 06:49:32 2026 +0000
[SPARK-60197][SQL][TEST] Add DROP TABLE SQL golden tests
### What changes were proposed in this pull request?
Related ticket:
[SPARK-60197](https://issues.apache.org/jira/browse/SPARK-60197).
Add `drop-table.sql` with execution and analyzer golden files generated by
Apache Spark's `SQLQueryTestSuite`.
The cases cover existing and missing tables, `IF EXISTS`, qualified names,
`PURGE`, local and global temporary views, `IDENTIFIER()`, and the legacy V1
command path. The V1 cases also verify that `DROP TABLE IF EXISTS` removes an
existing table and use `EXPLAIN` to check its plan for a missing table.
### Why are the changes needed?
Provide focused SQL golden coverage for `DROP TABLE` command resolution and
execution, including missing-table errors and legacy command compatibility.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Generated both golden files locally from OSS Spark, then ran the same tests
with regeneration disabled:
```sh
SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/testOnly
org.apache.spark.sql.SQLQueryTestSuite -- -z drop-table.sql"
build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z
drop-table.sql"
```
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-6).
Closes #59400 from vladanvasi-db/effort/spark-drop-table-goldens.
Authored-by: Vladan Vasić <[email protected]>
Signed-off-by: Uros Bojanic <[email protected]>
(cherry picked from commit ebed4bc1a443854b5c0d14579534643bea3092dc)
Signed-off-by: Uros Bojanic <[email protected]>
---
.../sql-tests/analyzer-results/drop-table.sql.out | 193 +++++++++++++++++
.../test/resources/sql-tests/inputs/drop-table.sql | 46 ++++
.../resources/sql-tests/results/drop-table.sql.out | 241 +++++++++++++++++++++
3 files changed, 480 insertions(+)
diff --git
a/sql/core/src/test/resources/sql-tests/analyzer-results/drop-table.sql.out
b/sql/core/src/test/resources/sql-tests/analyzer-results/drop-table.sql.out
new file mode 100644
index 000000000000..e47394345698
--- /dev/null
+++ b/sql/core/src/test/resources/sql-tests/analyzer-results/drop-table.sql.out
@@ -0,0 +1,193 @@
+-- Automatically generated by SQLQueryTestSuite
+-- !query
+CREATE TABLE drop_table_t1 (c INT) USING parquet
+-- !query analysis
+CreateDataSourceTableCommand `spark_catalog`.`default`.`drop_table_t1`, false
+
+
+-- !query
+DROP TABLE drop_table_t1
+-- !query analysis
+DropTable false, false
++- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.drop_table_t1
+
+
+-- !query
+CREATE TABLE drop_table_t2 (c INT) USING parquet
+-- !query analysis
+CreateDataSourceTableCommand `spark_catalog`.`default`.`drop_table_t2`, false
+
+
+-- !query
+DROP TABLE IF EXISTS drop_table_t2
+-- !query analysis
+DropTable true, false
++- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.drop_table_t2
+
+
+-- !query
+DROP TABLE IF EXISTS drop_table_missing
+-- !query analysis
+DropTable true, false
++- ResolvedIdentifier V2SessionCatalog(spark_catalog),
default.drop_table_missing
+
+
+-- !query
+DROP TABLE drop_table_missing
+-- !query analysis
+org.apache.spark.sql.catalyst.analysis.NoSuchTableException
+{
+ "errorClass" : "TABLE_OR_VIEW_NOT_FOUND",
+ "sqlState" : "42P01",
+ "messageParameters" : {
+ "relationName" : "`spark_catalog`.`default`.`drop_table_missing`",
+ "searchPath" : "[`spark_catalog`.`default`]"
+ }
+}
+
+
+-- !query
+CREATE TABLE drop_table_t3 (c INT) USING parquet
+-- !query analysis
+CreateDataSourceTableCommand `spark_catalog`.`default`.`drop_table_t3`, false
+
+
+-- !query
+DROP TABLE default.drop_table_t3
+-- !query analysis
+DropTable false, false
++- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.drop_table_t3
+
+
+-- !query
+CREATE TABLE drop_table_t4 (c INT) USING parquet
+-- !query analysis
+CreateDataSourceTableCommand `spark_catalog`.`default`.`drop_table_t4`, false
+
+
+-- !query
+DROP TABLE drop_table_t4 PURGE
+-- !query analysis
+DropTable false, true
++- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.drop_table_t4
+
+
+-- !query
+CREATE TEMPORARY VIEW drop_table_v1 AS SELECT 1 AS c
+-- !query analysis
+CreateViewCommand `drop_table_v1`, SELECT 1 AS c, false, false, LocalTempView,
UNSUPPORTED, true
+ +- Project [1 AS c#x]
+ +- OneRowRelation
+
+
+-- !query
+DROP TABLE drop_table_v1
+-- !query analysis
+DropTempViewCommand drop_table_v1, false
+
+
+-- !query
+DROP TABLE IF EXISTS drop_table_v1
+-- !query analysis
+DropTable true, false
++- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.drop_table_v1
+
+
+-- !query
+CREATE GLOBAL TEMPORARY VIEW drop_table_gv1 AS SELECT 1 AS c
+-- !query analysis
+CreateViewCommand `drop_table_gv1`, SELECT 1 AS c, false, false,
GlobalTempView, UNSUPPORTED, true
+ +- Project [1 AS c#x]
+ +- OneRowRelation
+
+
+-- !query
+DROP TABLE global_temp.drop_table_gv1
+-- !query analysis
+DropTempViewCommand global_temp.drop_table_gv1, false
+
+
+-- !query
+DROP TABLE IF EXISTS global_temp.drop_table_gv1
+-- !query analysis
+DropTable true, false
++- ResolvedIdentifier V2SessionCatalog(spark_catalog),
global_temp.drop_table_gv1
+
+
+-- !query
+CREATE TABLE drop_table_t6 (c INT) USING parquet
+-- !query analysis
+CreateDataSourceTableCommand `spark_catalog`.`default`.`drop_table_t6`, false
+
+
+-- !query
+DROP TABLE IDENTIFIER('drop_table_t6')
+-- !query analysis
+DropTable false, false
++- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.drop_table_t6
+
+
+-- !query
+SET spark.sql.legacy.useV1Command=true
+-- !query analysis
+SetCommand (spark.sql.legacy.useV1Command,Some(true))
+
+
+-- !query
+CREATE TABLE drop_table_t7 (c INT) USING parquet
+-- !query analysis
+CreateDataSourceTableCommand `spark_catalog`.`default`.`drop_table_t7`, false
+
+
+-- !query
+DROP TABLE drop_table_t7
+-- !query analysis
+DropTableCommand `spark_catalog`.`default`.`drop_table_t7`, false, false, false
+
+
+-- !query
+DROP TABLE IF EXISTS drop_table_missing
+-- !query analysis
+DropTableCommand `spark_catalog`.`default`.`drop_table_missing`, true, false,
false
+
+
+-- !query
+EXPLAIN DROP TABLE IF EXISTS drop_table_missing
+-- !query analysis
+ExplainCommand 'DropTable true, false, SimpleMode
+
+
+-- !query
+CREATE TABLE drop_table_t9 (c INT) USING parquet
+-- !query analysis
+CreateDataSourceTableCommand `spark_catalog`.`default`.`drop_table_t9`, false
+
+
+-- !query
+DROP TABLE IF EXISTS drop_table_t9
+-- !query analysis
+DropTableCommand `spark_catalog`.`default`.`drop_table_t9`, true, false, false
+
+
+-- !query
+SHOW TABLES LIKE 'drop_table_t9'
+-- !query analysis
+ShowTablesCommand default, drop_table_t9, [namespace#x, tableName#x,
isTemporary#x], false
+
+
+-- !query
+CREATE TABLE drop_table_t8 (c INT) USING parquet
+-- !query analysis
+CreateDataSourceTableCommand `spark_catalog`.`default`.`drop_table_t8`, false
+
+
+-- !query
+DROP TABLE drop_table_t8 PURGE
+-- !query analysis
+DropTableCommand `spark_catalog`.`default`.`drop_table_t8`, false, false, true
+
+
+-- !query
+SET spark.sql.legacy.useV1Command=false
+-- !query analysis
+SetCommand (spark.sql.legacy.useV1Command,Some(false))
diff --git a/sql/core/src/test/resources/sql-tests/inputs/drop-table.sql
b/sql/core/src/test/resources/sql-tests/inputs/drop-table.sql
new file mode 100644
index 000000000000..f804f1f53bd5
--- /dev/null
+++ b/sql/core/src/test/resources/sql-tests/inputs/drop-table.sql
@@ -0,0 +1,46 @@
+-- DROP TABLE on an existing table.
+CREATE TABLE drop_table_t1 (c INT) USING parquet;
+DROP TABLE drop_table_t1;
+
+-- DROP TABLE IF EXISTS on an existing and on a missing table.
+CREATE TABLE drop_table_t2 (c INT) USING parquet;
+DROP TABLE IF EXISTS drop_table_t2;
+DROP TABLE IF EXISTS drop_table_missing;
+
+-- DROP TABLE on a missing table.
+DROP TABLE drop_table_missing;
+
+-- DROP TABLE with a qualified name.
+CREATE TABLE drop_table_t3 (c INT) USING parquet;
+DROP TABLE default.drop_table_t3;
+
+-- DROP TABLE with PURGE.
+CREATE TABLE drop_table_t4 (c INT) USING parquet;
+DROP TABLE drop_table_t4 PURGE;
+
+-- DROP TABLE on a temporary view.
+CREATE TEMPORARY VIEW drop_table_v1 AS SELECT 1 AS c;
+DROP TABLE drop_table_v1;
+DROP TABLE IF EXISTS drop_table_v1;
+
+-- DROP TABLE on a global temporary view.
+CREATE GLOBAL TEMPORARY VIEW drop_table_gv1 AS SELECT 1 AS c;
+DROP TABLE global_temp.drop_table_gv1;
+DROP TABLE IF EXISTS global_temp.drop_table_gv1;
+
+-- DROP TABLE with an IDENTIFIER clause.
+CREATE TABLE drop_table_t6 (c INT) USING parquet;
+DROP TABLE IDENTIFIER('drop_table_t6');
+
+-- DROP TABLE via a v1 command.
+SET spark.sql.legacy.useV1Command=true;
+CREATE TABLE drop_table_t7 (c INT) USING parquet;
+DROP TABLE drop_table_t7;
+DROP TABLE IF EXISTS drop_table_missing;
+EXPLAIN DROP TABLE IF EXISTS drop_table_missing;
+CREATE TABLE drop_table_t9 (c INT) USING parquet;
+DROP TABLE IF EXISTS drop_table_t9;
+SHOW TABLES LIKE 'drop_table_t9';
+CREATE TABLE drop_table_t8 (c INT) USING parquet;
+DROP TABLE drop_table_t8 PURGE;
+SET spark.sql.legacy.useV1Command=false;
diff --git a/sql/core/src/test/resources/sql-tests/results/drop-table.sql.out
b/sql/core/src/test/resources/sql-tests/results/drop-table.sql.out
new file mode 100644
index 000000000000..89f40232f40d
--- /dev/null
+++ b/sql/core/src/test/resources/sql-tests/results/drop-table.sql.out
@@ -0,0 +1,241 @@
+-- Automatically generated by SQLQueryTestSuite
+-- !query
+CREATE TABLE drop_table_t1 (c INT) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE drop_table_t1
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE drop_table_t2 (c INT) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE IF EXISTS drop_table_t2
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE IF EXISTS drop_table_missing
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE drop_table_missing
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.catalyst.analysis.NoSuchTableException
+{
+ "errorClass" : "TABLE_OR_VIEW_NOT_FOUND",
+ "sqlState" : "42P01",
+ "messageParameters" : {
+ "relationName" : "`spark_catalog`.`default`.`drop_table_missing`",
+ "searchPath" : "[`spark_catalog`.`default`]"
+ }
+}
+
+
+-- !query
+CREATE TABLE drop_table_t3 (c INT) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE default.drop_table_t3
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE drop_table_t4 (c INT) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE drop_table_t4 PURGE
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TEMPORARY VIEW drop_table_v1 AS SELECT 1 AS c
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE drop_table_v1
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE IF EXISTS drop_table_v1
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE GLOBAL TEMPORARY VIEW drop_table_gv1 AS SELECT 1 AS c
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE global_temp.drop_table_gv1
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE IF EXISTS global_temp.drop_table_gv1
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE drop_table_t6 (c INT) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE IDENTIFIER('drop_table_t6')
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SET spark.sql.legacy.useV1Command=true
+-- !query schema
+struct<key:string,value:string>
+-- !query output
+spark.sql.legacy.useV1Command true
+
+
+-- !query
+CREATE TABLE drop_table_t7 (c INT) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE drop_table_t7
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE IF EXISTS drop_table_missing
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+EXPLAIN DROP TABLE IF EXISTS drop_table_missing
+-- !query schema
+struct<plan:string>
+-- !query output
+== Physical Plan ==
+Execute DropTableCommand
+ +- DropTableCommand `spark_catalog`.`default`.`drop_table_missing`, true,
false, false
+
+
+-- !query
+CREATE TABLE drop_table_t9 (c INT) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE IF EXISTS drop_table_t9
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SHOW TABLES LIKE 'drop_table_t9'
+-- !query schema
+struct<namespace:string,tableName:string,isTemporary:boolean>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE drop_table_t8 (c INT) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE drop_table_t8 PURGE
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SET spark.sql.legacy.useV1Command=false
+-- !query schema
+struct<key:string,value:string>
+-- !query output
+spark.sql.legacy.useV1Command false
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]