Skip to content

fix: handle shallow clones in dbt clone, table, and incremental rebuilds#1592

Open
saishreeeee wants to merge 6 commits into
databricks:mainfrom
saishreeeee:PECOBLR-3690
Open

fix: handle shallow clones in dbt clone, table, and incremental rebuilds#1592
saishreeeee wants to merge 6 commits into
databricks:mainfrom
saishreeeee:PECOBLR-3690

Conversation

@saishreeeee

@saishreeeee saishreeeee commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Resolves #1165

Description

Shallow clones have a distinct table_type that can't be changed in place, so dbt clone and table/incremental rebuilds over a clone failed (UPDATE_TABLE_TYPE, CLUSTER_BY_AUTO_UNSUPPORTED_TABLE_TYPE_ERROR).
Adds is_shallow_clone, drops the clone before recreating it (clone/table/incremental), and skips CLUSTER BY AUTO when altering a clone in place.

Checklist

  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt-databricks next" section.
  • [Optional] I have run /dbt-databricks-pr-ready (AI agent skill in .claude/skills/) and addressed its merge-readiness feedback

@saishreeeee saishreeeee changed the title fix: drop shallow clones before rebuild and skip CLUSTER BY AUTO on c… fix: handle shallow clones in dbt clone, table, and incremental rebuilds Jul 16, 2026
@saishreeeee
saishreeeee marked this pull request as ready for review July 17, 2026 04:42
Comment thread CHANGELOG.md
## dbt-databricks 1.12.3 (TBD)

### Fixes
- Fix rebuilding a table or incremental model over an existing shallow clone, and `dbt clone` over an existing managed table, failing with `INVALID_PARAMETER_VALUE.UPDATE_TABLE_TYPE`/`CLUSTER_BY_AUTO_UNSUPPORTED_TABLE_TYPE_ERROR`; the shallow clone is now dropped before it is recreated, and `CLUSTER BY AUTO` is skipped when altering a shallow clone in place ([#1592](https://github.com/databricks/dbt-databricks/pull/1592) resolves [#1165](https://github.com/databricks/dbt-databricks/issues/1165))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: let's keep the changelog comment terse (~1 line) and not add implementation specifics

shallow clone {{ defer_relation.render() }}
{% endmacro %}

{#-- Drop first unless already a shallow clone; `create or replace` can't change table_type in place. --#}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: we can remove the comment or make it more accurate here it is both table + shallow_clone

{% else %}
{#-- Relation must be dropped & recreated --#}
{% if not is_replaceable %} {#-- If Delta, we will `create or replace` below, so no need to drop --#}
{% if not is_replaceable or existing_relation.is_shallow_clone %} {#-- Delta uses `create or replace` below, except a shallow clone must be dropped (table_type can't change in place) --#}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: drop the (table_type can't change in place), mostly implementation details. better not to have in comment.

{%- elif existing_relation.is_view or existing_relation.is_materialized_view or existing_relation.is_streaming_table or should_full_refresh() -%}
{#-- Relation must be dropped & recreated --#}
{% if not is_replaceable_format %} {#-- If Delta or Iceberg, we will `create or replace` below, so no need to drop --#}
{% if not is_replaceable_format or existing_relation.is_shallow_clone %} {#-- Delta/Iceberg uses `create or replace` below, except a shallow clone must be dropped (table_type can't change in place) --#}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: drop (table_type can't change in place)

@@ -3,6 +3,7 @@
import pytest

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's look to add functional tests

@sd-db sd-db Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(a) clone --full-refresh over an existing managed table
(b) table/incremental rebuild over a shallow clone with auto_liquid_cluster, with information_schema
/ history assertions

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dbt clone doesn't work out of the box

2 participants