From 5210d0a9746443c8a2cf217c16c919a73f3ba543 Mon Sep 17 00:00:00 2001 From: Ben Schreiber <74134279+ben-schreiber@users.noreply.github.com> Date: Thu, 21 Dec 2023 19:45:14 +0200 Subject: [PATCH] Fix hardcoded file format in python materializations (#955) * Fix hardcoded file format in python materializations * Add changelog --- .changes/unreleased/Fixes-20231221-081949.yaml | 6 ++++++ dbt/include/spark/macros/materializations/table.sql | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Fixes-20231221-081949.yaml diff --git a/.changes/unreleased/Fixes-20231221-081949.yaml b/.changes/unreleased/Fixes-20231221-081949.yaml new file mode 100644 index 000000000..b10c8141e --- /dev/null +++ b/.changes/unreleased/Fixes-20231221-081949.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix hardcoded file format for python models +time: 2023-12-21T08:19:49.630806+02:00 +custom: + Author: ben-schreiber + Issue: "803" diff --git a/dbt/include/spark/macros/materializations/table.sql b/dbt/include/spark/macros/materializations/table.sql index 39a9caba9..b7c56c424 100644 --- a/dbt/include/spark/macros/materializations/table.sql +++ b/dbt/include/spark/macros/materializations/table.sql @@ -98,7 +98,7 @@ else: msg = f"{type(df)} is not a supported type for dbt Python materialization" raise Exception(msg) -df.write.mode("overwrite").format("delta").option("overwriteSchema", "true").saveAsTable("{{ target_relation }}") +df.write.mode("overwrite").format("{{ config.get('file_format', 'delta') }}").option("overwriteSchema", "true").saveAsTable("{{ target_relation }}") {%- endmacro -%} {%macro py_script_comment()%}