ulysses-you commented on a change in pull request #25198: [SPARK-28443][SQL] 
Spark sql add exception when create field type NullType
URL: https://github.com/apache/spark/pull/25198#discussion_r307059217
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/rules.scala
 ##########
 @@ -393,6 +393,42 @@ case class PreprocessTableInsertion(conf: SQLConf) 
extends Rule[LogicalPlan] {
   }
 }
 
+/**
+ * SPARK-28443: Spark sql add exception when create field type NullType
+ */
+object DDLCheck extends (LogicalPlan => Unit) {
+
+  def failAnalysis(msg: String): Unit = { throw new AnalysisException(msg) }
+
+  override def apply(plan: LogicalPlan): Unit = {
+    plan.foreach {
+      case ct: CreateTable if ct.tableDesc.schema.exists { f =>
+        DataTypes.NullType.sameType(f.dataType)
+      } =>
+        failAnalysis("DataType NullType is not supported for create table ")
+
+      case ct2: CreateV2Table if ct2.tableSchema.exists { f =>
+        DataTypes.NullType.sameType(f.dataType)
+      } =>
+        failAnalysis("DataType NullType is not supported for create table")
+
+      // DataSourceStrategy will convert CreateTable to 
CreateDataSourceTableCommand before check
+      case cdstc: CreateDataSourceTableCommand if cdstc.table.schema.exists { 
f =>
 
 Review comment:
   Thanks for your advise.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to