Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions tests/test_export_dbt_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines 208 to +215
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sample was not using generic table and column names, so I corrected them together.

}
)
}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
}
)
}
Expand All @@ -278,24 +278,24 @@ 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
materialized: table
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
Expand Down
Loading