Table materialization (V2) leads to unavailability of data
メンテナーはふだん 6 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 42/100
調査の方向性
docs/table_flow.md から始め、toto.sql モデル、toto.yml コントラクト、2 つの dbt run コマンドを使って失敗を再現します。テーブルのマテリアライゼーションフローを、言及されている insert_overwrite 戦略と比較します。完了の条件は、制約付きの実行が失敗しても有効な既存データが削除されず、テーブルが引き続き利用可能であることです。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
TLDR; stop using create or replace and then insert when table when table already exists (with valid data)
Two problems since materialization V2 for "table":
- The table materialization does 2 steps (create or replace + insert) that can lead to an unavailability of the data
- Constraints can be applied before hands (thanks a lot!) but the problem is that if new data arrive violating the said constraints afterward, we recreate the table first, hence removing all data.
The problem is that Delta is not handling transactions across multiple commands... One way to do overcome the second problem would be to add a clause for putting back data using RESTORE but it leaves the first problem.
Then, I thought of using the insert_overwrite incremental strategy that would replace all data in a single transaction, hence not removing existing valid data in a violation constraint scenario but the strategy isn't complete yet (not possible to add columns if I read right) and unavailable for SQL warehouse (even though I don't understand why because here would be a valid case for overwriting completely the table, maybe should have been only a warning in the logs?).
I think using insert_overwrite (without partition predicate) in the table materialization when the relation already exists in the database would be an idea but this may lead to complications (what if a column type changes ?). Happy to discuss !
Steps To Reproduce
Create a model toto.sql :
{{
config(
materialized = 'table',
)
}}
{% if load_relation(this) %} {# meaning it exists in the database #}
select null as name
union all
select 'toto' as name
{% else %} {# meaning it does not exist in the database #}
select 'toto' as name
{% endif %}
And its corresponding toto.yml
models:
- name: toto
config:
contract:
enforced: true
columns:
- name: name
data_type: string
constraints:
- type: not_null
Then run :
dbt run -s toto --> Succeed + select * from my_catalog.my_schema.toto returns 1 row
dbt run -s toto --> Fails + select * from my_catalog.my_schema.toto returns 0 row
Expected behavior
I want my valid data not to be removed and a 0 downtime of my table.
System information
The output of dbt --version:
Core:
- installed: 1.10.2
- latest: 1.10.5 - 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.4 - Up to date!
- spark: 1.9.2 - Update available!
At least one plugin is out of date with dbt-core.
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
The operating system you're using:
Mac OS
The output of python --version:
Python 3.13.5
Additional context
Thanks everyone for all the good work !! 🙏 I would be glad to contribute once we decide how to handle this problem ! Don't hesitate to reach out, we can even schedule a call if you have time for this.
- 主要言語
- Python
- スター
- 391
- フォーク
- 231
- 平均マージ
- 9日 7時間
- マージ済み PR(30日)
- 29
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
databricks/dbt-databricks のほかの issue
-
persist_docs.columns triggers a full-plan probe query on views even when the model has no column docs対応中かも @DelorneN007 が 59 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
databricks/dbt-databricks#1680 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
-
bug
難易度 2/5 半日 初心者へのやさしさ 68/100
databricks/dbt-databricks#1003 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
-
Emit COMMENT and DEFAULT for function arguments and descriptions in CREATE FUNCTION対応中かも @alvinism が 7 日前に担当しました。 オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
databricks/dbt-databricks#1764 ·
メンテナーはふだん 6 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 46/100
databricks/dbt-databricks#1762 ·
メンテナーはふだん 6 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
databricks/dbt-databricks#1761 ·
メンテナーはふだん 6 日以内に返信
databricks/dbt-databricks の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
FinanceFlash/unvibecode#699 ·
メンテナーはふだん 1 日以内に返信
-
enhancement Website
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OWASP/OWASP-Hunting#96 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
micropython/micropython#19942 ·
メンテナーはふだん 1 日以内に返信
-
A rebuild posts "not part of this build" success to the commit's failed `nix-build` gate and effects対応中かも @Padraic-O-Mhuiris が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
`epoch.Integer` raises a raw OverflowError for integers too large to convert to a float対応中かも @arindam77 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pydantic/pydantic-extra-types#479 ·
メンテナーはふだん 1 日以内に返信