Skip to content

fix: suppress warning on materialization v2 behavior flags.#1431

Open
tejassp-db wants to merge 4 commits intomainfrom
fix-mat_v2-warning
Open

fix: suppress warning on materialization v2 behavior flags.#1431
tejassp-db wants to merge 4 commits intomainfrom
fix-mat_v2-warning

Conversation

@tejassp-db
Copy link
Copy Markdown
Collaborator

Fixes #1089.

dbt-core's BehaviorFlag emits a deprecation warning the first time a flag with default=False is read. As a result, every dbt run with incremental materialization logs a confusing use_materialization_v2 warning on every model, with no clean way to silence it short of opting in to the flag itself.

This PR fixes this by accessing the flag with no_warn in the code paths. A new get_behavior_flag_no_warn helper on the adapter is decorated with @available so Jinja can call it at runtime. All four materialization macros that gate v1/v2 (table.sql, view.sql, seeds.sql, incremental.sql) now route through that helper, which reads the flag via BehaviorFlagRendered.no_warn and bypasses the BehaviorChangeEvent entirely.

PECOBLR-2649

Materialization v2 behavior flag is never going to be default true.
Suppress all warnings using no_warn calls in all code paths.
@tejassp-db tejassp-db changed the title fix suppress warning on materialization v2 behavior flags. fix: suppress warning on materialization v2 behavior flags. Apr 29, 2026
@github-actions
Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  dbt/adapters/databricks
  impl.py 770-771
Project Total  

This report was generated by python-coverage-comment-action

Copy link
Copy Markdown
Collaborator

@sd-db sd-db left a comment

Choose a reason for hiding this comment

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

Code changes look good, best to remove functional tests for the change

)
assert results[0][1] == expected_struct_type

def test_use_materialization_v2_warning_absent(self, project, my_table):
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.

We should not add any functional test for this change. Functional check general behaviour and should not be used to check for logs/messages. This is better to be had as unit tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed

Comment thread tests/unit/test_adapter.py Outdated

class TestMaterializationV2BehaviorFlag(DatabricksAdapterBase):
"""The `use_materialization_v2` deprecation warning must not fire on every dbt run.
The fix routes all 4 Jinja-side accesses through `adapter.get_behavior_flag_no_warn(...)`,
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: make comment less verbose/not leak specific implementation details.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

sd-db
sd-db previously approved these changes Apr 29, 2026
Copy link
Copy Markdown
Collaborator

@sd-db sd-db left a comment

Choose a reason for hiding this comment

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

Changes look good, there seems to be a stray line (probably an artifact from the recentl fixes, that we forgot ro remove)

from dbt.tests.adapter.materialized_view import files
from dbt.tests.adapter.materialized_view.basic import MaterializedViewBasic

from dbt.adapters.databricks.impl import USE_MATERIALIZATION_V2
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: stray line

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@tejassp-db
Copy link
Copy Markdown
Collaborator Author

/integration-test

@github-actions
Copy link
Copy Markdown

Integration tests dispatched for PR #1431 by @tejassp-db. Track progress in the Actions tab.

@github-actions
Copy link
Copy Markdown

Integration results for PR #1431 — UC cluster ❌ failure · SQL warehouse ✅ success · All-purpose cluster ❌ failure

Run details.

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.

How to silence deprecation warning about materialization v2?

2 participants