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

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 2.4.3
    • Fix Version/s: None
    • Component/s: Spark Core
    • Labels:
      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

            • Assignee:
              Unassigned
              Reporter:
              chris@buildlackey.com Chris Bedford
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: