cloud-fan commented on code in PR #55444:
URL: https://github.com/apache/spark/pull/55444#discussion_r3731271251


##########
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala:
##########
@@ -594,6 +594,29 @@ abstract class SQLQuerySuiteBase extends QueryTest with 
TestHiveSingleton {
     }
   }
 
+  test("SPARK-56558: CTAS IF NOT EXISTS Hive Table should be with non-existent 
" +
+    "or empty location") {
+    withSQLConf(SQLConf.ALLOW_NON_EMPTY_LOCATION_IN_CTAS.key -> "false") {
+      withTempDir { dir =>
+        val tempLocation = dir.toURI.toString
+        withTable("ctas1", "ctas_with_existing_location") {
+          sql(s"CREATE TABLE ctas1(id string) stored as rcfile LOCATION 
'$tempLocation/ctas1'")
+          sql("INSERT INTO TABLE ctas1 SELECT 'A' ")
+          // The target table does not exist in the catalog, so IF NOT EXISTS 
must not skip the
+          // non-empty location check and overwrite the location of table 
ctas1.

Review Comment:
   A location path is not overwritten; the data stored there is.
   
   ```suggestion
             // non-empty location check and overwrite the data of table ctas1.
   ```



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

To unsubscribe, e-mail: [email protected]

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