HeartSaVioR commented on a change in pull request #27107: [SPARK-30436][SQL] 
Allow CREATE EXTERNAL TABLE with only requiring LOCATION
URL: https://github.com/apache/spark/pull/27107#discussion_r363588306
 
 

 ##########
 File path: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
 ##########
 @@ -659,6 +659,34 @@ class HiveDDLSuite
       "partition column value"))
   }
 
+  test("create external table with default") {
+    val catalog = spark.sessionState.catalog
+    withTempDir { tmpDir =>
+      val externalTab = "extTable_with_defaults"
+      withTable(externalTab) {
+        assert(tmpDir.listFiles.isEmpty)
+        sql(
+          s"""
+             |CREATE EXTERNAL TABLE $externalTab (key INT, value STRING)
+             |LOCATION '${tmpDir.toURI}'
+          """.stripMargin)
+
+        val hiveTable = catalog.getTableMetadata(TableIdentifier(externalTab, 
Some("default")))
+        assert(hiveTable.tableType == CatalogTableType.EXTERNAL)
+
+        // Before data insertion, all the directory are empty
+        assert(tmpDir.listFiles == null || tmpDir.listFiles.isEmpty)
+
+        sql(s"INSERT INTO $externalTab VALUES (1, 'a')")
+        assert(tmpDir.listFiles.nonEmpty)
+
+        sql(s"DROP TABLE $externalTab")
+        // After data insertion, all the directory are not empty
+        assert(tmpDir.listFiles.nonEmpty)
 
 Review comment:
   Agreed. I'll remove these lines. Thanks for the suggestion.

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