LantaoJin commented on a change in pull request #28833:
URL: https://github.com/apache/spark/pull/28833#discussion_r448220808



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/CatalogV2Util.scala
##########
@@ -346,4 +346,23 @@ private[sql] object CatalogV2Util {
       }
     }
   }
+
+  def failNullType(dt: DataType): Unit = {
+    def containsNullType(dt: DataType): Boolean = dt match {
+      case ArrayType(et, _) => containsNullType(et)
+      case MapType(kt, vt, _) => containsNullType(kt) || containsNullType(vt)
+      case StructType(fields) => fields.exists(f => 
containsNullType(f.dataType))
+      case _ => dt.isInstanceOf[NullType]
+    }
+    if (containsNullType(dt)) {
+      throw new AnalysisException(
+        "Cannot create tables with VOID type.")

Review comment:
       I only tested in PostgreSQL and MySQL.
   No one can run
   `CREATE TABLE t (null_col NULL);`
   For 
   `CREATE TABLE t2 AS SELECT NULL as null_col`
   PostgreSQL shows
   ```
                   Table "public.t2"
     Column  | Type | Collation | Nullable | Default
   ----------+------+-----------+----------+---------
    null_col | text |           |          |
   ```
   And MYSQL shows
   ```
     Column  |    Type   | Nullable  | Default
   ----------+-----------+-----------+----------
    null_col | binary(0) |    YES    |  NULL
   ```




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



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

Reply via email to