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

<dataframe>.write.option("mode","overwrite").saveAsTable("foo") fails with 'already exists' if table foo exists

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 2.4.3
    • None
    • Spark Core
    • None

    Description

      I am guessing the bug title will be sufficient explanation of the issue.

      below is a little script to illustrate. Running the script gives this error:

       > org.apache.spark.sql.AnalysisException: Table `example` already exists.;

      spark.sql("drop table if exists example ").show()
      case class Person(first: String, last: String, age: Integer)
      val df = List(
      Person("joe", "x", 9),
      Person("fred", "z", 9)).toDF()
      df.write.option("mode","overwrite").saveAsTable("example")

      val recover1 = spark.read.table("example")
      recover1.show()

      val df3 = List(
      Person("mouse", "x", 9),
      Person("golf", "z", 9)).toDF()

      df3.write.option("mode","overwrite").saveAsTable("example")

      val recover4 = spark.read.table("example")
      recover4.show()

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            chris@buildlackey.com Chris Bedford
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: