Python model - more customization options
Maintainer thường phản hồi trong vòng 6 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- data-engineering
Hướng nghiên cứu
Bắt đầu bằng cách đọc dbt/include/databricks/macros/adapters/python.sql, đặc biệt là databricks__py_write_table và py_get_writer_options, sau đó so sánh macro ghi đè và cấu hình model được hiển thị ở đây. Hãy xác định tùy biến được hỗ trợ cho các tùy chọn ghi và việc xử lý ref, cùng với cấu hình và tài liệu của chúng, trước khi triển khai và xác thực hành vi đã thống nhất.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the feature
The current Python model macro is quite restrictive:
- Model is forced to do full overwrite: https://github.com/databricks/dbt-databricks/blob/main/dbt/include/databricks/macros/adapters/python.sql#L42
- Model hardcodes the interface used to read refs.
Would it be possible to offer more customization (e.g. including the overwriteSchema as option into py_get_writer_options() ?
Would it also be possible to allow more customization on the way refs are treated?
Describe alternatives you've considered
The alternative I went for now is overriding this macro. I don't mind, but I'm wondering if there could be a better way?
Additional context
Here is the macro I'm using (yes, i essentially just cut everything out, and changed spark.table to str):
{% macro databricks__py_write_table(compiled_code, target_relation) %}
{{ compiled_code }}
dbt = dbtObj(str)
df = model(dbt, spark)
{% endmacro %}
And here is my model:
version: 2
models:
- name: test_model
config:
test_var: "{{ var('test_var') }}"
materialized: "table"
submission_method: "serverless_cluster"
partition_by:
- test_var
columns:
- name: test_var
data_type: int
- name: some_data
data_type: int
from datetime import datetime, timedelta
def model(dbt, session):
test_var = dbt.config.get("test_var", None)
partition_by = dbt.config.get('partition_by', [])
query = f"""
select
'{test_var}' as test_var,
123 as some_data
from {dbt.ref('other_sql_model')}
where test_var = '{test_var}'
"""
df = session.sql(query)
target_table = f"{dbt.this.database}.{dbt.this.schema}.{dbt.this.identifier}"
print(f"Target table: {target_table}")
(
df.write
.mode("overwrite")
.format("delta")
.option("partitionOverwriteMode", "dynamic")
.partitionBy(*partition_by)
.saveAsTable(target_table)
)
return session.table(target_table)
Who will this benefit?
I think this customization (and associated documentation) would benefit teams that consider migrating to dbt, but having a lot of legacy python pipelines. Wrapping those pipelines with dbt with such simplified macro will allow "lift and shift" kind of move, and then gradual evolution of the pipelines to become more dbt-friendly.
Are you interested in contributing this feature?
I am happy to contribute, but I'd like to hear some critique and arguments against this. Overall, my primary interest is to enable usage of dbt also for the cases where logic is objectively too complex to be migrated to SQL in any reasonable time.
- Ngôn ngữ chính
- Python
- Star
- 391
- Fork
- 231
- Merge trung bình
- 9 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 29
Chuẩn bị môi trường
- 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 databricks/dbt-databricks
-
persist_docs.columns triggers a full-plan probe query on views even when the model has no column docsCó thể đã có người làm @DelorneN007 đã nhận 59 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
databricks/dbt-databricks#1680 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
-
bug
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 68/100
databricks/dbt-databricks#1003 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Emit COMMENT and DEFAULT for function arguments and descriptions in CREATE FUNCTIONCó thể đã có người làm @alvinism đã nhận 7 ngày trước. Đang mởenhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
databricks/dbt-databricks#1764 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 46/100
databricks/dbt-databricks#1762 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
databricks/dbt-databricks#1761 ·
Maintainer thường phản hồi trong vòng 6 ngày
Tất cả issue của databricks/dbt-databricks
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
FinanceFlash/unvibecode#699 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement Website
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OWASP/OWASP-Hunting#96 ·
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 78/100
micropython/micropython#19942 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A rebuild posts "not part of this build" success to the commit's failed `nix-build` gate and effectsCó thể đã có người làm @Padraic-O-Mhuiris đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`epoch.Integer` raises a raw OverflowError for integers too large to convert to a floatCó thể đã có người làm @arindam77 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pydantic/pydantic-extra-types#479 ·
Maintainer thường phản hồi trong vòng 1 ngày