cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

ENABLE CHANGE DATA FEED FOR EXISTING DELTA-TABLE

yatharthmahesh
New Contributor III

I have a delta table already created, now I want to enable the change data feed. I read that I have to set delta.enableChangeDataFeed property to true. But however, this cannot be done using the Scala API. I tried using this but it didn't work. I am using the OS version (delta) for performing all these operations.

I really appreciate any help you can provide.

val ddl_query = """CREATE TABLE if not exists delta_training.delta_table
                   USING DELTA
                   LOCATION '/Users/data-partner-merge/src/main/resources/delta/dpm/base'
                   """
 //creation of table
 spark.sql(ddl_query)
 
 spark.sql(" ALTER TABLE delta_training.onaudience_dpm SET TBLPROPERTIES ('delta.enableChangeDataFeed' = true )").show()

 EDIT 1: As mentioned by a user, I tried using this as well, but still no changes come into action.

spark.sql(" ALTER TABLE delta_training.onaudience_dpm SET TBLPROPERTIES (delta.enableChangeDataFeed = true)")

4 REPLIES 4

Hubert-Dudek
Esteemed Contributor III

'delta.enableChangeDataFeed' have to be without quotes.

 spark.sql("ALTER TABLE delta_training.onaudience_dpm SET TBLPROPERTIES (delta.enableChangeDataFeed = true)").show()

I tried but that doesn't work

Can you try in plain SQL instead of spark.sql() API? According to the docs, this is the command to do it :

ALTER TABLE myDeltaTable SET TBLPROPERTIES (delta.enableChangeDataFeed = true)

docs https://docs.databricks.com/delta/delta-change-data-feed.html#enable-change-data-feed

Kaniz
Community Manager
Community Manager

Hi @Yatharth Maheshwari​, We haven’t heard from you on the last response from @Jose Gonzalez​, and I was checking back to see if his suggestions helped you.

Or else, If you have any solution, please do share that with the community as it can be helpful to others.

Also, Please don't forget to click on the "Select As Best" button whenever the information provided helps resolve your question.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!