vladanvasi-db commented on code in PR #60100:
URL: https://github.com/apache/spark/pull/60100#discussion_r4478793935


##########
sql/core/src/test/resources/sql-tests/inputs/create-table.sql:
##########
@@ -0,0 +1,90 @@
+--SET spark.sql.sources.default=parquet

Review Comment:
   Changed the file-level default to `json` and regenerated both golden 
families. The only expected-output change is `SHOW CREATE TABLE 
ct_default_provider` now using `json`; generation and comparison each passed 
both tests. Fixed in `c6b89e5b471`.



##########
sql/core/src/test/resources/sql-tests/inputs/create-table.sql:
##########
@@ -0,0 +1,90 @@
+--SET spark.sql.sources.default=parquet
+--SET 
spark.sql.catalog.testcat=org.apache.spark.sql.connector.catalog.InMemoryTableCatalog
+
+-- CREATE TABLE behavior in the session catalog and a V2 catalog.
+CREATE NAMESPACE testcat.ns;
+CREATE TABLE ct_v1 (c INT, s STRING COMMENT 'x') USING parquet;
+CREATE TABLE testcat.ns.ct_v2 (c INT, s STRING COMMENT 'x') USING parquet;
+
+-- Omitting USING selects the configured default provider.
+CREATE TABLE ct_default_provider (c INT);
+SHOW CREATE TABLE ct_default_provider;
+
+-- IF NOT EXISTS preserves the existing schema, even when a different schema 
is supplied.
+CREATE TABLE IF NOT EXISTS ct_v1 (c INT) USING parquet;
+CREATE TABLE IF NOT EXISTS testcat.ns.ct_v2 (c INT) USING parquet;
+DESCRIBE ct_v1;
+DESCRIBE testcat.ns.ct_v2;
+
+-- Creating an existing table without IF NOT EXISTS fails in both catalogs.
+CREATE TABLE ct_v1 (c INT) USING parquet;
+CREATE TABLE testcat.ns.ct_v2 (c INT) USING parquet;
+
+-- Duplicate column names, including case variants.
+CREATE TABLE ct_dup (a INT, a STRING) USING parquet;
+CREATE TABLE ct_dup (a INT, A STRING) USING parquet;
+
+-- Nested types and nullability.
+CREATE TABLE ct_nested (
+  st STRUCT<b: INT, c: STRING>,
+  m MAP<STRING, INT>,
+  arr ARRAY<INT>,
+  arr_st ARRAY<STRUCT<x: INT, y: STRING>>
+) USING parquet;
+DESCRIBE ct_nested;
+CREATE TABLE ct_not_null (c INT NOT NULL, s STRING) USING parquet;

Review Comment:
   Added a note naming `spark.sql.fileSource.insert.enforceNotNull=false` and 
explaining that the default V1 file-source behavior stores a nullable schema. 
This case's golden output is unchanged. Fixed in `c6b89e5b471`.



##########
sql/core/src/test/resources/sql-tests/inputs/create-table.sql:
##########
@@ -0,0 +1,90 @@
+--SET spark.sql.sources.default=parquet
+--SET 
spark.sql.catalog.testcat=org.apache.spark.sql.connector.catalog.InMemoryTableCatalog
+
+-- CREATE TABLE behavior in the session catalog and a V2 catalog.
+CREATE NAMESPACE testcat.ns;
+CREATE TABLE ct_v1 (c INT, s STRING COMMENT 'x') USING parquet;
+CREATE TABLE testcat.ns.ct_v2 (c INT, s STRING COMMENT 'x') USING parquet;
+
+-- Omitting USING selects the configured default provider.
+CREATE TABLE ct_default_provider (c INT);
+SHOW CREATE TABLE ct_default_provider;
+
+-- IF NOT EXISTS preserves the existing schema, even when a different schema 
is supplied.
+CREATE TABLE IF NOT EXISTS ct_v1 (c INT) USING parquet;
+CREATE TABLE IF NOT EXISTS testcat.ns.ct_v2 (c INT) USING parquet;
+DESCRIBE ct_v1;
+DESCRIBE testcat.ns.ct_v2;
+
+-- Creating an existing table without IF NOT EXISTS fails in both catalogs.
+CREATE TABLE ct_v1 (c INT) USING parquet;
+CREATE TABLE testcat.ns.ct_v2 (c INT) USING parquet;
+
+-- Duplicate column names, including case variants.
+CREATE TABLE ct_dup (a INT, a STRING) USING parquet;
+CREATE TABLE ct_dup (a INT, A STRING) USING parquet;
+
+-- Nested types and nullability.
+CREATE TABLE ct_nested (
+  st STRUCT<b: INT, c: STRING>,
+  m MAP<STRING, INT>,
+  arr ARRAY<INT>,
+  arr_st ARRAY<STRUCT<x: INT, y: STRING>>
+) USING parquet;
+DESCRIBE ct_nested;
+CREATE TABLE ct_not_null (c INT NOT NULL, s STRING) USING parquet;
+SHOW CREATE TABLE ct_not_null;
+
+-- Day-time interval columns in V1 and V2 tables.
+CREATE TABLE ct_interval (i INTERVAL DAY) USING parquet;
+CREATE TABLE testcat.ns.ct_interval (i INTERVAL DAY) USING parquet;
+DESCRIBE ct_interval;
+DESCRIBE testcat.ns.ct_interval;
+
+-- Qualified names: a valid schema and a missing schema.
+CREATE TABLE default.ct_qualified (c INT) USING parquet;
+CREATE TABLE ct_no_such_schema.ct_x (c INT) USING parquet;
+
+-- A named parameter supplies the CREATE TABLE identifier in dynamic SQL.
+EXECUTE IMMEDIATE 'CREATE TABLE IDENTIFIER(:n) (c INT) USING parquet' USING 
'ct_exec' AS n;
+DESCRIBE ct_exec;
+
+-- Unknown data source provider and reserved table property.
+CREATE TABLE ct_bad_provider (c INT) USING no_such_provider;
+CREATE TABLE ct_reserved (c INT) USING parquet TBLPROPERTIES ('provider' = 
'parquet');
+
+-- A table without an explicit collation inherits its schema's default 
collation.
+CREATE SCHEMA ct_coll_schema DEFAULT COLLATION UTF8_LCASE;
+CREATE TABLE ct_coll_schema.ct_coll (s STRING) USING parquet;
+SHOW CREATE TABLE ct_coll_schema.ct_coll;
+
+-- REPLACE requires an existing V2 table; V1 tables do not support replacement.

Review Comment:
   Reworded both REPLACE blocks to distinguish the session catalog's provider 
check from the V2 catalog's table-existence requirement. All recorded successes 
and error classes are unchanged. Fixed in `c6b89e5b471`.



-- 
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]

Reply via email to