You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 30d9aec
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
-`datacontract import postgres` imports primary and foreign keys from the Postgres catalog, also for SELECT-only roles (#1709@vtulus)
15
15
-`datacontract edit`: enable the editor's AI assistant via `DATACONTRACT_EDITOR_AI_*` environment variables (endpoint, API key, model, provider, auth header)
16
16
-`datacontract test`: check constraints and quality rules on nested properties on Athena and Trino servers
17
-
-`datacontract export sql`: export a schema with `physicalType: view` as a view that selects from its `transformSourceObjects` (#1031)
17
+
-`datacontract export sql`: export a schema with `physicalType: view` as a view that selects from its `transformSourceObjects`, joined on its relationships (#1031)
18
18
19
19
### Fixed
20
20
-`datacontract lint` and `datacontract test`: warn about unknown fields, such as a misspelled `quality`, instead of silently ignoring them (will be an error in the next major version in January 2027)
A schema with `physicalType: view` is exported as a `CREATE OR REPLACE VIEW` (`CREATE OR ALTER VIEW` on SQL Server) that selects its properties from the tables listed in their `transformSourceObjects`. Snowflake and Databricks views keep the column and view descriptions as comments.
57
+
A schema with `physicalType: view` is exported as a `CREATE OR REPLACE VIEW` (`CREATE OR ALTER VIEW` on SQL Server) that selects each property from the object in its `transformSourceObjects`. An entry whose last part is the property's name, such as `bronze.orders.order_id`, is read as that column of the object. Snowflake and Databricks views keep the column and view descriptions as comments.
58
+
59
+
When the properties come from several source objects, they are joined with `LEFT JOIN`, starting from the first object, on the `foreignKey` relationships of the view. A `customers.id` reference points to the source object `customers` or `<schema>.customers`.
58
60
59
61
```yaml
60
62
schema:
@@ -63,19 +65,25 @@ schema:
63
65
properties:
64
66
- name: order_id
65
67
transformSourceObjects: [bronze.orders]
68
+
- name: customer_id
69
+
transformSourceObjects: [bronze.orders]
70
+
relationships:
71
+
- to: customers.id
66
72
- name: customer_name
67
73
transformSourceObjects: [bronze.customers]
68
74
```
69
75
70
76
```sql
71
77
CREATE OR REPLACE VIEW orders_enriched AS
72
78
SELECT
73
-
order_id,
74
-
customer_name
75
-
FROM bronze.orders, bronze.customers;
79
+
orders.order_id,
80
+
orders.customer_id,
81
+
customers.customer_name
82
+
FROM bronze.orders orders
83
+
LEFT JOIN bronze.customers customers ON orders.customer_id = customers.id;
76
84
```
77
85
78
-
Several source objects are listed in one `FROM` clause; add the join condition by hand. A view without any `transformSourceObjects`is exported as a table.
86
+
A view is exported as a table, with a warning, when its properties have no `transformSourceObjects` or when a source object is not joined to the others by a relationship.
0 commit comments