Try to initialize a Delta table object in your Spark environment usinyou already have :
from delta.tables import DeltaTable
deltaTable = DeltaTable.forPath(spark, "abfss://******@xyz.dfs.core.windows.net/main/testcdc")
Once you have the Delta table object, use the setTableProperties
method to enable the Change Data Feed :
deltaTable.setTableProperties({"delta.enableChangeDataFeed": "true"})
If you prefer Spark SQL, you might need to create a temporary view pointing to your Delta table and then use the ALTER TABLE
command on that view. This approach may not be supported for path-based Delta tables in all environments.