From 8cf6815e42c934f8fbf41b0a24b15c9776b31dcd Mon Sep 17 00:00:00 2001 From: Toshifumi Suga Date: Thu, 25 Sep 2025 15:14:50 +0900 Subject: [PATCH] fix changelog --- CHANGELOG.md | 1 + tests/test_export_dbt_models.py | 40 ++++++++++++++++----------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c785d8ac..0cf3abd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Import the table tags from a open data contract spec v3 (#895) +- dbt export: Enhanced model-level primaryKey support with automatic test generation for single and multiple column primary keys (#898) ## [0.10.35] - 2025-08-25 diff --git a/tests/test_export_dbt_models.py b/tests/test_export_dbt_models.py index a3f4ff37..8e7abf18 100644 --- a/tests/test_export_dbt_models.py +++ b/tests/test_export_dbt_models.py @@ -206,13 +206,13 @@ def test_to_dbt_models_with_model_level_composite_primary_key(): id="my-data-contract-id", info=Info(title="My Data Contract", version="0.0.1"), models={ - "sfdc_loc_tenants_test": Model( + "test_table": Model( type="table", - primaryKey=["tenant_id", "account_id"], # Model-level composite primary key + primaryKey=["order_id", "user_id"], # Model-level composite primary key fields={ - "tenant_id": Field(type="string", required=True), - "account_id": Field(type="string", required=True), - "name": Field(type="string", required=True) + "order_id": Field(type="string", required=True), + "user_id": Field(type="string", required=True), + "product_id": Field(type="string", required=True) } ) } @@ -221,7 +221,7 @@ def test_to_dbt_models_with_model_level_composite_primary_key(): expected_dbt_model = """ version: 2 models: - - name: sfdc_loc_tenants_test + - name: test_table config: meta: data_contract: my-data-contract-id @@ -231,18 +231,18 @@ def test_to_dbt_models_with_model_level_composite_primary_key(): data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - - tenant_id - - account_id + - order_id + - user_id columns: - - name: tenant_id + - name: order_id data_type: STRING constraints: - type: not_null - - name: account_id + - name: user_id data_type: STRING constraints: - type: not_null - - name: name + - name: product_id data_type: STRING constraints: - type: not_null @@ -263,13 +263,13 @@ def test_to_dbt_models_with_single_column_primary_key(): id="my-data-contract-id", info=Info(title="My Data Contract", version="0.0.1"), models={ - "sfdc_loc_tenants_test": Model( + "test_table": Model( type="table", - primaryKey=["tenant_id"], # Model-level single primary key + primaryKey=["order_id"], # Model-level single primary key fields={ - "tenant_id": Field(type="string", required=True), - "account_id": Field(type="string", required=True), - "name": Field(type="string", required=True) + "order_id": Field(type="string", required=True), + "user_id": Field(type="string", required=True), + "product_id": Field(type="string", required=True) } ) } @@ -278,7 +278,7 @@ def test_to_dbt_models_with_single_column_primary_key(): expected_dbt_model = """ version: 2 models: - - name: sfdc_loc_tenants_test + - name: test_table config: meta: data_contract: my-data-contract-id @@ -286,16 +286,16 @@ def test_to_dbt_models_with_single_column_primary_key(): contract: enforced: true columns: - - name: tenant_id + - name: order_id data_type: STRING constraints: - type: not_null - type: unique - - name: account_id + - name: user_id data_type: STRING constraints: - type: not_null - - name: name + - name: product_id data_type: STRING constraints: - type: not_null