How to change the column datatype of a delta table

Shukla, Mayank - Vendor 1 Reputation point

How to change the column datatype of a delta table

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,031 questions
{count} votes

1 answer

Sort by: Most helpful
  1. KranthiPakala-MSFT 46,432 Reputation points Microsoft Employee

    Hello @Shukla, Mayank - Vendor ,

    As per the discussion with internal team, unfortunately there is no ALTER TABLE ALTER COLUMN at this moment. The possible workaround suggested is to change a datatype by reading the data in datafram using PySpark as shown below:

    df = df.withColumn("id", col("colname").cast("newdatatype")) # changes a column datatype.   

    Then to write it back to the delta table:

    df.write.format("delta").mode("overwrite").option("overwriteSchema", "true").save(folder_path) # overwrites the delta table and is another version:  

    If you have any feedback regarding this, I would recommend you to please log a feature request in IDEAS forum here -


    All the feedback shared in this forum are actively monitored and reviewed by product team who are responsible for building it and will take action accordingly. Please do share the feedback link once it is posted so that others can up-vote and comment on it to help increase the priority of the feature request.

    Hope this info helps.

    1 person found this answer helpful.