Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16672#discussion_r101388447
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala 
---
    @@ -1816,4 +1816,123 @@ class DDLSuite extends QueryTest with 
SharedSQLContext with BeforeAndAfterEach {
           }
         }
       }
    +
    +  test("insert data to a data source table which has a not existed 
location should succeed") {
    +    withTable("t") {
    +      withTempDir { dir =>
    +        spark.sql(
    +          s"""
    +             |CREATE TABLE t(a string, b int)
    +             |USING parquet
    +             |OPTIONS(path "$dir")
    +           """.stripMargin)
    +        val table = 
spark.sessionState.catalog.getTableMetadata(TableIdentifier("t"))
    +        val expectedPath = dir.getAbsolutePath.stripSuffix("/")
    +        assert(table.location.stripSuffix("/") == expectedPath)
    +
    +        dir.delete
    +        val tableLocFile = new File(table.location.stripPrefix("file:"))
    +        assert(!tableLocFile.exists)
    +        spark.sql("INSERT INTO TABLE t SELECT 'c', 1")
    +        assert(tableLocFile.exists)
    +        checkAnswer(spark.table("t"), Row("c", 1) :: Nil)
    +
    +        Utils.deleteRecursively(dir)
    +        assert(!tableLocFile.exists)
    +        spark.sql("INSERT OVERWRITE TABLE t SELECT 'c', 1")
    +        assert(tableLocFile.exists)
    +        checkAnswer(spark.table("t"), Row("c", 1) :: Nil)
    +
    +        val newDir = dir.getAbsolutePath.stripSuffix("/") + "/x"
    --- End diff --
    
    nit: `new File(dir, "x")`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to