1. Apache Spark 3.4.1 Documentation
SQL
Data Sources
Load and Save Functions
Save Modes:
Section: "Save Modes"
Content: The documentation explicitly states for ErrorIfExists (default): "When saving a DataFrame to a data source
if data/table already exists
an exception is expected to be thrown." This confirms the failure behavior.
URL: https://spark.apache.org/docs/3.4.1/sql-data-sources-load-save-functions.html#save-modes
2. Apache Spark 3.4.1 Documentation
API for Scala
org.apache.spark.sql.DataFrameWriter:
Method: saveAsTable(tableName: String)
Content: The documentation for the DataFrameWriter class describes the saveAsTable method as the way to save the content of the DataFrame as the specified table. This distinguishes it from the save(path: String) method
which writes to a path.
URL: https://spark.apache.org/docs/3.4.1/api/scala/org/apache/spark/sql/DataFrameWriter.html#saveAsTable(tableName:String):Unit
3. Databricks Documentation
Create a table:
Section: "Create a table from a DataFrame"
Content: This page provides examples of creating tables using df.write.saveAsTable("tablename")
establishing it as the correct method for the task. It also links to save options
including the different modes.
URL: https://docs.databricks.com/en/tables/create.html#create-a-table-from-a-dataframe