Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/15983
  
    We are facing another behavior inconsistency between `CTAS + Append` and 
`Insert Into`, because CTAS always repairt the table but InsertInto does not do 
it. Below is an example. 
    
    ```Scala
      test("append with saveAsTable + partition management") {
        withSQLConf(SQLConf.HIVE_MANAGE_FILESOURCE_PARTITIONS.key -> "true") {
          withTable("test") {
            withTempDir { dir =>
              setupPartitionedDatasourceTable("test", dir)
              spark.range(2).selectExpr("id as fieldOne", "id as partCol")
                .write.partitionBy("partCol").mode("append").saveAsTable("test")
              // all the partitions are visible
              assert(spark.sql("select * from test").count() == 7)
            }
          }
        }
      }
    
    
      test("insertInto + partition management") {
        withSQLConf(SQLConf.HIVE_MANAGE_FILESOURCE_PARTITIONS.key -> "true") {
          withTable("test") {
            withTempDir { dir =>
              setupPartitionedDatasourceTable("test", dir)
              spark.range(2).selectExpr("id as fieldOne", "id as partCol")
                .write.insertInto("test")
              // only the involved partitions are visible
              assert(spark.sql("select * from test").count() == 4)
            }
          }
        }
      }
    ```


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to