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_r309464688
##########
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) {
+ if (create.partitioning.nonEmpty) {
+ throw new AnalysisException("It is not allowed to specify partition
columns when the " +
Review comment:
Here's the rule:
https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala#L302-L315
Looks like that is only applied to CTAS. Maybe we should also match
CreateTable instead of adding additional logic here.
----------------------------------------------------------------
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]