Skip to content

Enable Delta Change Data Feed globally for all spellbook tables#9892

Open
shahil-bhikha wants to merge 1 commit into
mainfrom
enable-delta-cdf
Open

Enable Delta Change Data Feed globally for all spellbook tables#9892
shahil-bhikha wants to merge 1 commit into
mainfrom
enable-delta-cdf

Conversation

@shahil-bhikha

Copy link
Copy Markdown

Add delta.enableChangeDataFeed = true to the create_table_properties macro to enable CDC for all Delta tables created by dbt, both in production and CI.

This applies globally at CREATE TABLE time via the WITH clause for all models using file_format = 'delta' (100+ models across all sub-projects).

Property is rendered via dune_properties() macro into valid Trino SQL and applies to prod, dev, and CI equally. CDC is required for downstream datashare replication pipelines.

Add delta.enableChangeDataFeed = true to the create_table_properties macro
to enable CDC for all Delta tables created by dbt, both in production and CI.
This applies globally at CREATE TABLE time via the WITH clause for all models
using file_format = 'delta' (100+ models across all sub-projects).

Property is rendered via dune_properties() macro into valid Trino SQL and
applies to prod, dev, and CI equally. CDC is required for downstream datashare
replication pipelines.
@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Wide blast radius across every Delta table on recreate, but limited to a standard table property with no query or auth changes.

Overview
Adds delta.enableChangeDataFeed = true to the shared create_table_properties macro so every Delta table built through trino__create_table_as gets CDC enabled at CREATE OR REPLACE time in the Trino WITH clause (via dune_properties()).

This is a global default for prod, dev, and CI—not per-model config—so it affects all spellbook Delta table / incremental models on the next full table rebuild, supporting downstream datashare replication that depends on change data feed.

Reviewed by Cursor Bugbot for commit 9ab5751. Configure here.

@github-actions
github-actions Bot marked this pull request as draft July 16, 2026 10:10
@github-actions github-actions Bot added the WIP work in progress label Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@shahil-bhikha

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@shahil-bhikha
shahil-bhikha marked this pull request as ready for review July 16, 2026 10:11
github-actions Bot added a commit that referenced this pull request Jul 16, 2026
@github-actions github-actions Bot added ready-for-review this PR development is complete, please review and removed WIP work in progress labels Jul 16, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: CDC on temporary staging tables
    • I passed the temporary flag into create_table_properties and now only enable delta.enableChangeDataFeed when the table is not temporary.

Create PR

Or push these changes by commenting:

@cursor push b4936268e8
Preview (b4936268e8)
diff --git a/dbt_macros/dune/adapters.sql b/dbt_macros/dune/adapters.sql
--- a/dbt_macros/dune/adapters.sql
+++ b/dbt_macros/dune/adapters.sql
@@ -4,7 +4,7 @@
     {%- do _properties.update({'partitioned_by': "ARRAY['" + (config.get('partition_by') | join("', '") )  + "']"}) -%}
   {%- endif -%}
   create or replace table {{ relation }}
-    {{ create_table_properties(_properties, relation) }}
+    {{ create_table_properties(_properties, relation, temporary) }}
   as (
     {{ sql }}
   );
@@ -45,14 +45,16 @@
   {%- endif -%}
 {%- endmacro -%}
 
-{% macro create_table_properties(_properties, relation) %}
+{% macro create_table_properties(_properties, relation, temporary=false) %}
   {%- if not (target.name == 'ci' and target.database == 'dune') -%}
     {%- set modified_identifier = relation.identifier | replace("__dbt_tmp", "") -%}
     {%- set unique_location = modified_identifier ~ '_' ~ time_salted_md5_prefix() -%}
     {%- set location= 's3a://%s/%s/%s' % (s3_bucket(), relation.schema, unique_location) -%}
     {%- do _properties.update({'location': "'" + location + "'"}) -%}
   {%- endif -%}
-  {%- do _properties.update({'delta.enableChangeDataFeed': 'true'}) -%}
+  {%- if not temporary -%}
+    {%- do _properties.update({'delta.enableChangeDataFeed': 'true'}) -%}
+  {%- endif -%}
   {%- if target.name == 'ci' -%}
     {%- do _properties.update({'extra_properties': "map_from_entries(ARRAY[ROW('dune.public', 'true')])"}) -%}
   {%- endif -%}

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9ab5751. Configure here.

{%- set location= 's3a://%s/%s/%s' % (s3_bucket(), relation.schema, unique_location) -%}
{%- do _properties.update({'location': "'" + location + "'"}) -%}
{%- endif -%}
{%- do _properties.update({'delta.enableChangeDataFeed': 'true'}) -%}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CDC on temporary staging tables

Medium Severity

Change Data Feed is now set for every create_table_properties call, including short-lived __dbt_tmp staging tables built during incremental and table materializations. Those relations are created through trino__create_table_as with temporary=true, but that flag is never passed into create_table_properties, so CDC can be enabled on tables meant only for load-time swaps rather than datashare replication targets.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9ab5751. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review this PR development is complete, please review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant