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:ย 

How to enable CDF when saveAsTable from pyspark code?

drag7ter
New Contributor III

I'm running this code in databricks notebook and I want the table from dataframe in catalog were created with CDF enables. When I run the code table hasn't exited yet.

This code doesn't create a table with enables CDF. It doesn't add:

delta.enableChangeDataFeed = true
 df \
.write \
.format("delta") \
.mode("overwrite") \
.option("overwriteSchema", "true") \
.option("delta.enableChangeDataFeed", "true") \
.saveAsTable(my_table_name_in_catalog): 

 Or it is possible only enable it via Spark SQL, after table already exists?

1 ACCEPTED SOLUTION

Accepted Solutions

raphaelblg
Databricks Employee
Databricks Employee

Hello @drag7ter ,

I don't see anything wrong with your approach, check my repro:

raphaelblg_0-1712936628123.png

 

 

Best regards,

Raphael Balogo
Sr. Technical Solutions Engineer
Databricks

View solution in original post

2 REPLIES 2

raphaelblg
Databricks Employee
Databricks Employee

Hello @drag7ter ,

I don't see anything wrong with your approach, check my repro:

raphaelblg_0-1712936628123.png

 

 

Best regards,

Raphael Balogo
Sr. Technical Solutions Engineer
Databricks

drag7ter
New Contributor III

Hi @raphaelblg in your screenshot cdcTest table already exists in unity catalog, or it will be created for the first time, running your code? It is really strange as I'm not able to enable from the pyspark code, only after tables created ALTER TABLES works.

"delta.enableChangeDataFeed", "true"

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group