Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-18543

SaveAsTable(CTAS) using overwrite could change table definition

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.6.3, 2.0.2
    • Fix Version/s: None
    • Component/s: SQL
    • Labels:
      None

      Description

      When the mode is OVERWRITE, we drop the Hive serde tables and create a data source table. This is not right.

          val tableName = "tab1"
          withTable(tableName) {
            sql(s"CREATE TABLE $tableName STORED AS SEQUENCEFILE AS SELECT 1 AS key, 'abc' AS value")
            val df = sql(s"SELECT key, value FROM $tableName")
            df.write.mode(SaveMode.Overwrite).saveAsTable(tableName)
            val tableMeta = spark.sessionState.catalog.getTableMetadata(TableIdentifier(tableName))
            assert(tableMeta.provider == Some(spark.sessionState.conf.defaultDataSourceName))
          }
      

      Based on the definition of OVERWRITE, no change should be made on the table definition. When recreate the table, we need to create a Hive serde table.

        Attachments

          Activity

            People

            • Assignee:
              smilegator Xiao Li
              Reporter:
              smilegator Xiao Li
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: