rdblue commented on a change in pull request #25305: [SPARK-28572][SQL] Simple 
analyzer checks for CREATE TABLE v2
URL: https://github.com/apache/spark/pull/25305#discussion_r309463958
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceResolution.scala
 ##########
 @@ -245,6 +246,55 @@ case class DataSourceResolution(
       catalog: TableCatalog,
       identifier: Identifier,
       create: CreateTableStatement): CreateV2Table = {
+
+    val isCaseSensitive = conf.caseSensitiveAnalysis
+    // Check that columns are not duplicated in the schema
+    val flattenedSchema = 
SchemaUtils.explodeNestedFieldNames(create.tableSchema)
+    SchemaUtils.checkColumnNameDuplication(
+      flattenedSchema,
+      s"in the table definition of ${identifier.quoted}",
+      isCaseSensitive)
+
+    // Check that columns are not duplicated in the partitioning statement
+    SchemaUtils.checkTransformDuplication(
+      create.partitioning, "in the partition schema", isCaseSensitive)
+
+    // Check that columns are not duplicated in the bucketing specification
+    SchemaUtils.checkTransformDuplication(
+      create.bucketSpec.map(_.asTransform).toSeq, "in the bucket definition", 
isCaseSensitive)
+    if (create.tableSchema.isEmpty) {
 
 Review comment:
   I don't think creating a table with an empty schema should be allowed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to