beliefer commented on a change in pull request #23841: [SPARK-26936][SQL] Fix 
bug of insert overwrite local dir and inconsistent behavior with Hive
URL: https://github.com/apache/spark/pull/23841#discussion_r260170709
 
 

 ##########
 File path: sql/hive/src/test/scala/org/apache/spark/sql/hive/InsertSuite.scala
 ##########
 @@ -581,6 +581,38 @@ class InsertSuite extends QueryTest with 
TestHiveSingleton with BeforeAndAfter
     }
   }
 
+  test("insert overwrite to not exists dir from hive metastore table") {
+    withTempDir { dir =>
+      val path = dir.toURI.getPath
+      val notExistsPath = s"${path}/src/result"
+
+      sql(s"INSERT OVERWRITE LOCAL DIRECTORY '${notExistsPath}' SELECT * FROM 
src where key < 10")
+
+      sql(
+        s"""
+           |INSERT OVERWRITE LOCAL DIRECTORY '${notExistsPath}'
+           |STORED AS orc
+           |SELECT * FROM src where key < 10
+         """.stripMargin)
+
+      // use orc data source to check the data of path is right.
+      withTempView("orc_source") {
+        sql(
+          s"""
+             |CREATE TEMPORARY VIEW orc_source
+             |USING org.apache.spark.sql.hive.orc
+             |OPTIONS (
+             |  PATH '${notExistsPath}'
+             |)
+           """.stripMargin)
+
+        checkAnswer(
+          sql("select * from orc_source"),
+          sql("select * from src where key < 10"))
 
 Review comment:
   These code refers to the writing of other UT.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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]

Reply via email to