From 94251a072c72982ea839ea12f78c5aba2e9dc8fa Mon Sep 17 00:00:00 2001 From: Elazar Lachkar Date: Tue, 26 May 2026 18:40:03 +0300 Subject: [PATCH 1/2] Fix microbatch integration test event_time type for Fabric. Use DbtProject.is_tsql to select datetime2 on T-SQL targets instead of checking sqlserver only. Co-authored-by: Cursor --- .../test_microbatch_compiled_code.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/integration_tests/tests/test_dbt_artifacts/test_microbatch_compiled_code.py b/integration_tests/tests/test_dbt_artifacts/test_microbatch_compiled_code.py index 60e49fb36..14d0e22da 100644 --- a/integration_tests/tests/test_dbt_artifacts/test_microbatch_compiled_code.py +++ b/integration_tests/tests/test_dbt_artifacts/test_microbatch_compiled_code.py @@ -4,22 +4,22 @@ from dbt_project import DbtProject -def _microbatch_source_model_sql() -> str: - return """ -{{ config(event_time='order_date') }} -{% set event_time_data_type = 'datetime2' if target.type == 'sqlserver' else 'timestamp' %} +def _microbatch_source_model_sql(dbt_project: DbtProject) -> str: + event_time_data_type = "datetime2" if dbt_project.is_tsql else "timestamp" + return f""" +{{{{ config(event_time='order_date') }}}} select 1 as order_id, 1 as customer_id, 42 as amount, - cast('2024-01-01 00:00:00' as {{ event_time_data_type }}) as order_date + cast('2024-01-01 00:00:00' as {event_time_data_type}) as order_date union all select 2 as order_id, 2 as customer_id, 84 as amount, - cast('2025-01-01 00:00:00' as {{ event_time_data_type }}) as order_date + cast('2025-01-01 00:00:00' as {event_time_data_type}) as order_date """ @@ -59,7 +59,7 @@ def _with_microbatch_test_models(dbt_project: DbtProject, model_suffix: str): f"{target_model_name}.sql" ) - source_model_path.write_text(_microbatch_source_model_sql()) + source_model_path.write_text(_microbatch_source_model_sql(dbt_project)) target_model_path.write_text(_microbatch_model_sql(source_model_name)) relative_source_model_path = source_model_path.relative_to( dbt_project.project_dir_path From 25a7b0629737ef1fe8331487be4879865c5033a9 Mon Sep 17 00:00:00 2001 From: Elazar Lachkar Date: Tue, 26 May 2026 19:26:15 +0300 Subject: [PATCH 2/2] Use elementary.edr_type_timestamp() in microbatch test model SQL. Lets adapter dispatch pick the correct timestamp type for Fabric and other targets. Co-authored-by: Cursor --- .../test_microbatch_compiled_code.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/integration_tests/tests/test_dbt_artifacts/test_microbatch_compiled_code.py b/integration_tests/tests/test_dbt_artifacts/test_microbatch_compiled_code.py index 14d0e22da..98cabc80a 100644 --- a/integration_tests/tests/test_dbt_artifacts/test_microbatch_compiled_code.py +++ b/integration_tests/tests/test_dbt_artifacts/test_microbatch_compiled_code.py @@ -4,22 +4,21 @@ from dbt_project import DbtProject -def _microbatch_source_model_sql(dbt_project: DbtProject) -> str: - event_time_data_type = "datetime2" if dbt_project.is_tsql else "timestamp" - return f""" -{{{{ config(event_time='order_date') }}}} +def _microbatch_source_model_sql() -> str: + return """ +{{ config(event_time='order_date') }} select 1 as order_id, 1 as customer_id, 42 as amount, - cast('2024-01-01 00:00:00' as {event_time_data_type}) as order_date + cast('2024-01-01 00:00:00' as {{ elementary.edr_type_timestamp() }}) as order_date union all select 2 as order_id, 2 as customer_id, 84 as amount, - cast('2025-01-01 00:00:00' as {event_time_data_type}) as order_date + cast('2025-01-01 00:00:00' as {{ elementary.edr_type_timestamp() }}) as order_date """ @@ -59,7 +58,7 @@ def _with_microbatch_test_models(dbt_project: DbtProject, model_suffix: str): f"{target_model_name}.sql" ) - source_model_path.write_text(_microbatch_source_model_sql(dbt_project)) + source_model_path.write_text(_microbatch_source_model_sql()) target_model_path.write_text(_microbatch_model_sql(source_model_name)) relative_source_model_path = source_model_path.relative_to( dbt_project.project_dir_path