dbt-databricks icon indicating copy to clipboard operation
dbt-databricks copied to clipboard

dbt clone doesn't work out of the box

Open oruen opened this issue 1 year ago • 3 comments

Describe the bug

Cloning a model via dbt clone command on serverless workspace for a managed delta table resulted in [RequestId=1415b41d-fefe-4a27-b085-31ab9782d23b ErrorClass=INVALID_PARAMETER_VALUE.UPDATE_TABLE_TYPE] Changing table_type is not supported.

Steps To Reproduce

  1. Have a table-materialized model like this one:
{{ config(materialized='table') }}
select
    ref_code
from
    {{ source('consoledb', 'ref_codes') }}
  1. Fetch the latest production manifest files and put them to "prod_target" folder
  2. Attepmt cloning a table via dbt
dbt clone --state prod_target --full-refresh --exclude-resource-type snapshot --exclude config.materialized:udf -s stg_ops_ref_codes

Expected behavior

The model table in my development schema should've been replaced by a shallow clone of the production data.

Screenshots and log output

dbt clone --state prod_target --full-refresh --exclude-resource-type snapshot --exclude config.materialized:udf -s stg_ops_ref_codes
16:24:11  Running with dbt=1.10.3
16:24:13  Registered adapter: databricks=1.10.10
16:24:13  Unable to do partial parsing because config vars, config profile, or config target have changed
16:24:17  Found 429 models, 12 snapshots, 4 analyses, 949 data tests, 8 seeds, 353 sources, 1115 macros
16:24:17  
16:24:17  Concurrency: 4 threads (target='dev')
16:24:17  
16:24:35  
16:24:35  Completed with 1 error, 0 partial successes, and 0 warnings:
16:24:35  
16:24:35  Failure in model stg_ops_ref_codes (models/stage/console/stg_ops_ref_codes.sql)
16:24:35    Database Error in model stg_ops_ref_codes (models/stage/console/stg_ops_ref_codes.sql)
  [RequestId=8d7224c5-432e-476e-938d-84767adbe80b ErrorClass=INVALID_PARAMETER_VALUE.UPDATE_TABLE_TYPE] Changing table_type is not supported.

System information

The output of dbt --version:

Core:
  - installed: 1.10.3
  - latest:    1.10.9 - Update available!

  Your version of dbt-core is out of date!
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

Plugins:
  - databricks: 1.10.10 - Up to date!
  - spark:      1.9.2   - Update available!

The operating system you're using: macOS

The output of python --version: Python 3.11.4

Additional context

If I manually drop the table, cloning works. But then when I'd like to replace the shallow clone with a locally build version of the table I run into another error, which is caused by the same root cause — different table types:

Database Error in model stg_ops_ref_codes (models/stage/console/stg_ops_ref_codes.sql)
  [CLUSTER_BY_AUTO_UNSUPPORTED_TABLE_TYPE_ERROR] CLUSTER BY AUTO is only supported on UC Managed tables. SQLSTATE: 56038

oruen avatar Aug 28 '25 10:08 oruen

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue.

github-actions[bot] avatar Apr 09 '26 02:04 github-actions[bot]

This is still an active issue and not stale

tweavers avatar Jun 19 '26 22:06 tweavers

We ended up solving this by creating a global post-hook in dbt_project.yml in place of the +auto_liquid_cluster setting. hoping this can find its way into the official codebase:

{% macro dbx_auto_cluster() %}
  {%- if not execute -%}
    {{ return('') }}
  {%- endif -%}

  {%- set materialization = config.get('materialized') -%}
  {%- if materialization not in ['table', 'incremental', 'snapshot', 'seed'] -%}
    {{ return('') }}
  {%- endif -%}

  {%- if materialization in ['incremental', 'snapshot'] -%}
    {%- set query -%}
      select table_type
      from {{ this.database }}.information_schema.tables
      where table_catalog = '{{ this.database }}'
        and table_schema  = '{{ this.schema }}'
        and table_name    = '{{ this.identifier }}'
    {%- endset -%}

    {%- set results = run_query(query) -%}
    {%- set table_type = results.rows[0][0] if results.rows | length > 0 else none -%}

    {%- if table_type == 'MANAGED_SHALLOW_CLONE' -%}
      {{ return('') }}
    {%- endif -%}
  {%- endif -%}

  {{ return('alter table ' ~ this ~ ' cluster by auto') }}

tweavers avatar Jun 21 '26 03:06 tweavers