Skip to content

Commit a8aa951

Browse files
joostboonclaude
andcommitted
style: fix formatting in files introduced by master commit 91d04fd
Rebase onto master picked up a new commit that added microbatch files without running pre-commit. Apply black/isort/sqlfmt/prettier so code-quality CI passes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ce65e58 commit a8aa951

4 files changed

Lines changed: 38 additions & 29 deletions

File tree

integration_tests/dbt_project/dbt_project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ models:
3131
+file_format: "{{ 'delta' if target.type in ['spark', 'fabricspark'] else none }}"
3232

3333
flags:
34-
require_batched_execution_for_custom_microbatch_strategy: True
34+
require_batched_execution_for_custom_microbatch_strategy: True

integration_tests/tests/test_dbt_artifacts/test_microbatch_compiled_code.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from contextlib import contextmanager
22

33
import pytest
4-
54
from dbt_project import DbtProject
65

76

@@ -44,20 +43,30 @@ def _microbatch_model_sql(source_model_name: str) -> str:
4443
amount,
4544
order_date
4645
from {{ ref('__MICROBATCH_SOURCE_MODEL__') }}
47-
""".replace("__MICROBATCH_SOURCE_MODEL__", source_model_name)
46+
""".replace(
47+
"__MICROBATCH_SOURCE_MODEL__", source_model_name
48+
)
4849

4950

5051
@contextmanager
5152
def _with_microbatch_test_models(dbt_project: DbtProject, model_suffix: str):
5253
source_model_name = f"mb_src_{model_suffix}"
5354
target_model_name = f"mb_tgt_{model_suffix}"
54-
source_model_path = dbt_project.tmp_models_dir_path.joinpath(f"{source_model_name}.sql")
55-
target_model_path = dbt_project.tmp_models_dir_path.joinpath(f"{target_model_name}.sql")
55+
source_model_path = dbt_project.tmp_models_dir_path.joinpath(
56+
f"{source_model_name}.sql"
57+
)
58+
target_model_path = dbt_project.tmp_models_dir_path.joinpath(
59+
f"{target_model_name}.sql"
60+
)
5661

5762
source_model_path.write_text(_microbatch_source_model_sql())
5863
target_model_path.write_text(_microbatch_model_sql(source_model_name))
59-
relative_source_model_path = source_model_path.relative_to(dbt_project.project_dir_path)
60-
relative_target_model_path = target_model_path.relative_to(dbt_project.project_dir_path)
64+
relative_source_model_path = source_model_path.relative_to(
65+
dbt_project.project_dir_path
66+
)
67+
relative_target_model_path = target_model_path.relative_to(
68+
dbt_project.project_dir_path
69+
)
6170
try:
6271
yield relative_source_model_path, relative_target_model_path, target_model_name
6372
finally:
@@ -75,9 +84,7 @@ def _run_microbatch_model_and_get_latest_success_result(
7584
model_path,
7685
target_model_name,
7786
):
78-
dbt_project.dbt_runner.run(
79-
select=f"{source_model_path} {model_path}"
80-
)
87+
dbt_project.dbt_runner.run(select=f"{source_model_path} {model_path}")
8188

8289
unique_id = f"model.elementary_tests.{target_model_name}"
8390
run_results = dbt_project.read_table(
@@ -91,14 +98,14 @@ def _run_microbatch_model_and_get_latest_success_result(
9198

9299
@contextmanager
93100
def _with_microbatch_macro_file(dbt_project: DbtProject, macro_name: str):
94-
macro_path = (
95-
dbt_project.project_dir_path / "macros" / "microbatch.sql"
96-
)
101+
macro_path = dbt_project.project_dir_path / "macros" / "microbatch.sql"
97102
macro_sql = """
98103
{% macro __MACRO_NAME__(arg_dict) %}
99104
{{ return(elementary.get_incremental_microbatch_sql(arg_dict)) }}
100105
{% endmacro %}
101-
""".replace("__MACRO_NAME__", macro_name)
106+
""".replace(
107+
"__MACRO_NAME__", macro_name
108+
)
102109
if macro_path.exists():
103110
raise FileExistsError(f"Expected no macro file at {macro_path}")
104111

@@ -110,7 +117,9 @@ def _with_microbatch_macro_file(dbt_project: DbtProject, macro_name: str):
110117
macro_path.unlink()
111118

112119

113-
@pytest.mark.skip_targets(["spark", "vertica", "bigquery", "athena", "clickhouse", "dremio"])
120+
@pytest.mark.skip_targets(
121+
["spark", "vertica", "bigquery", "athena", "clickhouse", "dremio"]
122+
)
114123
@pytest.mark.skip_for_dbt_fusion
115124
@pytest.mark.parametrize(
116125
"macro_name,expected_compiled_code,model_suffix",
@@ -134,10 +143,10 @@ def test_microbatch_run_results_compiled_code_behavior(
134143
)
135144
assert run_results, "Expected a successful run result row for microbatch model"
136145
if expected_compiled_code:
137-
assert run_results[0]["compiled_code"], (
138-
"Expected compiled_code to be populated when override macro is present"
139-
)
146+
assert run_results[0][
147+
"compiled_code"
148+
], "Expected compiled_code to be populated when override macro is present"
140149
else:
141-
assert not run_results[0]["compiled_code"], (
142-
"Expected compiled_code to stay empty when override macro is absent"
143-
)
150+
assert not run_results[0][
151+
"compiled_code"
152+
], "Expected compiled_code to stay empty when override macro is absent"

macros/edr/dbt_artifacts/microbatch/capture_microbatch_compiled_code.sql

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@
3131
model.get("unique_id") if model is mapping else model.unique_id
3232
) | default(none, true) %}
3333
{% set model_compiled_code = (
34-
model.get("compiled_code") if model is mapping else model.compiled_code
34+
model.get("compiled_code")
35+
if model is mapping
36+
else model.compiled_code
3537
) | default(none, true) %}
36-
{% if model_unique_id is none %}
37-
{{ return(none) }}
38-
{% endif %}
39-
{% if not model_compiled_code %}
40-
{{ return(none) }}
41-
{% endif %}
38+
{% if model_unique_id is none %} {{ return(none) }} {% endif %}
39+
{% if not model_compiled_code %} {{ return(none) }} {% endif %}
4240
4341
{% set compiled_code_by_unique_id = elementary.get_cache(
4442
"microbatch_compiled_code_by_unique_id"

macros/utils/graph/get_compiled_code.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"microbatch_compiled_code_by_unique_id", {}
66
).get(node.get("unique_id")) %}
77
{% endif %}
8-
{% set compiled_code = adapter.dispatch("format_compiled_code", "elementary")(compiled_code) %}
8+
{% set compiled_code = adapter.dispatch("format_compiled_code", "elementary")(
9+
compiled_code
10+
) %}
911

1012
{% set max_column_size = elementary.get_column_size() %}
1113
{% if as_column_value and max_column_size and compiled_code and compiled_code | length > max_column_size %}

0 commit comments

Comments
 (0)