{"record":{"id":"f5dbed99ecb118fc","repo":"dbt-labs/dbt-core","slug":"both-zorder-and-liquid-clustering-are-set-but-they","errorCode":null,"errorMessage":"Both zorder and liquid_clustering are set but they are incompatible. zorder will be ignored.","messagePattern":"Both zorder and liquid_clustering are set but they are incompatible\\. zorder will be ignored\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/dbt-loader/src/dbt_macro_assets/dbt-databricks/macros/relations/optimize.sql","lineNumber":22,"sourceCode":"\n{%- macro databricks__optimize(relation) -%}\n  {%- if config.get('skip_optimize', false) | as_bool -%}\n  {%- elif var('DATABRICKS_SKIP_OPTIMIZE', 'false')|lower != 'true' and\n        var('databricks_skip_optimize', 'false')|lower != 'true' and\n        adapter.resolve_file_format(config) == 'delta' -%}\n    {%- if (config.get('zorder', False) or config.get('liquid_clustered_by', False)) or config.get('auto_liquid_cluster', False) -%}\n      {%- call statement('run_optimize_stmt') -%}\n        {{ get_optimize_sql(relation) }}\n      {%- endcall -%}\n    {%- endif -%}\n  {%- endif -%}\n{%- endmacro -%}\n\n{%- macro get_optimize_sql(relation) %}\n  optimize {{ relation.render() }}\n  {%- if config.get('zorder', False) and adapter.resolve_file_format(config) == 'delta' %}\n    {%- if config.get('liquid_clustered_by', False) or config.get('auto_liquid_cluster', False) %}\n      {{ exceptions.warn(\"Both zorder and liquid_clustering are set but they are incompatible. zorder will be ignored.\") }}\n    {%- else %}\n      {%- set zorder = config.get('zorder', none) %}\n      {# TODO: predicates here? WHERE ...  #}\n      {%- if zorder is sequence and zorder is not string %}\n        zorder by (\n        {%- for col in zorder %}\n        {{ col }}{% if not loop.last %}, {% endif %}\n        {%- endfor %}\n        )\n      {%- else %}\n        zorder by ({{zorder}})\n      {%- endif %}\n    {%- endif %}\n  {%- endif %}\n{%- endmacro -%}\n","sourceCodeStart":4,"sourceCodeEnd":38,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-loader/src/dbt_macro_assets/dbt-databricks/macros/relations/optimize.sql#L4-L38","documentation":"Delta tables support either ZORDER optimization or liquid clustering, but not both. In `get_optimize_sql`, if the model config sets both `zorder` and (`liquid_clustered_by` or `auto_liquid_cluster`), dbt warns that zorder will be ignored and emits `optimize` without a zorder clause.","triggerScenarios":"A Delta model sets `config.zorder` AND (`config.liquid_clustered_by` or `config.auto_liquid_cluster`); the `optimize` operation runs (post-hook/on incremental optimize).","commonSituations":"Enabling auto liquid clustering on an existing table that still carries a legacy `zorder` config; team-wide config defaults adding liquid clustering while individual models set zorder; switching clustering strategy without cleaning up the old key.","solutions":["Remove the `zorder` config from the model since liquid clustering takes precedence","Or remove `liquid_clustered_by`/`auto_liquid_cluster` if you intend to keep ZORDER","Centralize clustering config in one place (e.g. a shared macro) so both keys can't be set simultaneously"],"exampleFix":"# before\n{{ config(materialized='incremental', zorder=['user_id'], liquid_clustered_by=['user_id']) }}\n# after\n{{ config(materialized='incremental', liquid_clustered_by=['user_id']) }}","handlingStrategy":"validation","validationCode":"def check_clustering_conflict(model):\n    cfg = model.get('config', {})\n    if cfg.get('zorder') and (cfg.get('liquid_clustered_by') or cfg.get('auto_liquid_cluster')):\n        raise ValueError(f\"{model['name']}: set both zorder and liquid clustering; zorder will be ignored\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one clustering strategy per model — zorder OR liquid clustering","Provide team defaults via a shared macro that errors on both keys","Audit models for legacy `zorder` when enabling auto liquid clustering","Watch for this warning in logs after clustering migrations"],"tags":["databricks","zorder","liquid-clustering","conflicting-config"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}