Fabric: false destructive change on SCD2 `valid_from`/`valid_to` because `TIMESTAMP` and `DATETIME2(6)` are seen as different types
Maintainer thường phản hồi trong vòng 4 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 53/100
Hướng nghiên cứu
Start with sqlmesh/core/schema_diff.py and the Fabric adapter’s MSSQLEngineAdapter.columns() implementation. Reproduce the issue with the provided get_schema_differ("fabric") snippet, then check how dialect-rendered types are compared and how DATETIME_PRECISION is queried. Done means the comparison emits only ADD c for the repro and the existing datetime2 precision is read correctly.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
On Fabric (SQLMesh 0.236.4), adding a nullable column to an existing SCD_TYPE_2_BY_COLUMN model fails the plan:
ALTER TABLE .. ADD cancelled_flag BIT
ALTER TABLE .. DROP COLUMN _dwh_valid_from
ALTER TABLE .. ADD _dwh_valid_from DATETIME2(6)
ALTER TABLE .. DROP COLUMN _dwh_valid_to
ALTER TABLE .. ADD _dwh_valid_to DATETIME2(6)
Error: Plan requires a destructive change to a forward-only model.
Allowing it would wipe all SCD2 history.
Cause
- The plan's destructive check compares the old and new
columns_to_types, including the SCD2 managed columns. - The stored snapshot has
DATETIME2(6), while the new model keeps the genericTIMESTAMP. Both render asDATETIME2(6)in Fabric. SchemaDiffercompares the raw types, sees a type change, and plans DROP + ADD.
Repro
from sqlglot import exp
from sqlmesh.core.schema_diff import get_schema_differ
sd = get_schema_differ("fabric")
cur = {"v": exp.DataType.build("DATETIME2(6)", dialect="fabric")}
new = {"v": exp.DataType.build("TIMESTAMP"), "c": exp.DataType.build("BIT")}
print([o.expression.sql("fabric") for o in sd.compare_columns("t", cur, new)])
# actual: ADD c, DROP v, ADD v DATETIME2(6)
# expected: ADD c
Proposed fix
- Treat types that render identically in the dialect as unchanged. In
SchemaDiffer(or inPlanBuilderbefore callingcompare_columns):
exp.DataType.build(t.sql(dialect), dialect=dialect) - Add
DATETIME_PRECISIONto the column query inMSSQLEngineAdapter.columns(). Today an existingdatetime2(6)column is read back asdatetime2, which counts as(7).
- Ngôn ngữ chính
- Python
- Star
- 3.3k
- Fork
- 471
- Merge trung bình
- 6 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 35
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SQLMesh/sqlmesh
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
SQLMesh/sqlmesh#6008 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
VSCode Extension: SQLMesh LSP crashes on startup: ImportError: cannot import name 'WorkspaceDiagnosticRefreshRequest' with lsprotocol 2025.xCó thể đã có người làm @boomesh11 đã nhận 15 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Improvement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
SQLMesh/sqlmesh#5696 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của SQLMesh/sqlmesh
Issue tương tự
-
[BUG][Low–Medium] founder_numbers.py silently reads a SAFE discount or pool target given as a fraction (0.2) as 0.2%Có thể đã có người làm @sumitkhond111-del đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bmad-code-org/BMAD-METHOD#3358 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
open-mmlab/mmcv#3352 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
OpenGithubs/weekly#263 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
comp/cli P3 type/feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
NousResearch/hermes-agent#162784 ·
Maintainer thường phản hồi trong vòng 1 ngày