Update data type of a column within a table that has a GENERATED ALWAYS AS IDENTITY-column
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 07:04 AM
I want to cast the data type of a column "X" in a table "A" where column "ID" is defined as GENERATED ALWAYS AS IDENTITY.
Databricks refer to overwrite to achieve this: https://docs.databricks.com/delta/update-schema.html
The following operation:
(spark.read.table('A')
.withColumn("X", col("X").cast("string"))
.write
.mode("overwrite")
.option("overwriteSchema", "true")
.saveAsTable('A')
)
Returns this error message:
AnalysisException: Providing values for GENERATED ALWAYS AS IDENTITY column ID is not supported.
How can I cast columns for tables with GENERATED ALWAYS AS IDENTITY-columns? The same applies to renaming columns.
Labels: