|
| 1 | +import pytest |
| 2 | + |
1 | 3 | from dbt_project import DbtProject |
2 | 4 |
|
3 | 5 |
|
| 6 | +@pytest.mark.skip_targets(["vertica"]) |
| 7 | +@pytest.mark.skip_for_dbt_fusion |
4 | 8 | def test_microbatch_run_results_has_compiled_code(test_id: str, dbt_project: DbtProject): |
5 | 9 | dbt_project.dbt_runner.vars["disable_run_results"] = False |
6 | 10 |
|
7 | 11 | model_sql = """ |
8 | | -{{ config( |
9 | | - materialized='incremental', |
10 | | - incremental_strategy='microbatch', |
11 | | - event_time='order_date', |
12 | | - batch_size='year', |
13 | | - begin='2025-03-01', |
14 | | - unique_key='order_id' |
15 | | -) }} |
| 12 | +{% set model_config = { |
| 13 | + "materialized": "incremental", |
| 14 | + "incremental_strategy": "microbatch", |
| 15 | + "event_time": "order_date", |
| 16 | + "batch_size": "year", |
| 17 | + "begin": "2025-03-01", |
| 18 | + "unique_key": "order_id" |
| 19 | +} %} |
| 20 | +{% if target.type == "bigquery" %} |
| 21 | + {% do model_config.update( |
| 22 | + {"partition_by": {"field": "order_date", "data_type": "timestamp", "granularity": "year"}} |
| 23 | + ) %} |
| 24 | +{% endif %} |
| 25 | +{% if target.type == "athena" %} |
| 26 | + {% do model_config.update({"partitioned_by": ["order_date"]}) %} |
| 27 | +{% endif %} |
| 28 | +{{ config(**model_config) }} |
16 | 29 |
|
17 | 30 | select |
18 | | - cast(one as int) as order_id, |
| 31 | + cast({{ elementary.escape_reserved_keywords("one") }} as int) as order_id, |
19 | 32 | 1 as customer_id, |
20 | 33 | 42 as amount, |
21 | 34 | {{ dbt.current_timestamp() }} as order_date |
|
0 commit comments