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

Unable to overwrite table created by another Spark session

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Incomplete
    • 2.4.4
    • None
    • PySpark

    Description

      I'm unable to save a dataframe to a table, even when passing the `mode='overwrite'` argument:

       

      def test_pyspark_can_overwrite_table():
          spark = SparkSession.builder.getOrCreate()
          sdf = spark.createDataFrame([('Alice', 1)])
          sdf.write.saveAsTable('alice')
          spark.stop()
          spark = SparkSession.builder.getOrCreate()
          sdf = spark.createDataFrame([('Alice', 1)])
          sdf.write.saveAsTable('alice', mode='overwrite')
      

      I would expect this to succeed. Instead, I get the output in the attached file. The root exception reads:

      pyspark.sql.utils.AnalysisException: "Can not create the managed table('`alice`'). The associated location('file:/Users/dlindelof/Work/lodging-brain-mod-lever/scripts/Python/godfather/spark-warehouse/alice') already exists.;"
      

       

       

      Attachments

        1. pyspark.out
          9 kB
          David Lindelöf

        Activity

          People

            Unassigned Unassigned
            dlindelof David Lindelöf
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: