🧃 SQLMesh Bot 🧃 #15
GitHub Actions / SQLMesh - Prod Environment Synced
succeeded
Apr 10, 2024 in 26s
Deployed to Prod
Generated Prod Plan
Directly Modified: demo.customers (Indirect Non-breaking)
---
+++
@@ -2,12 +2,28 @@
name demo.orders,
dialect bigquery,
audits (unique_values('columns' = (
- order_id
+ surrogate_key
)), not_null('columns' = (
- order_id
+ surrogate_key
))),
grains (order_id)
)
+import sqlglot.expressions as exp
+def gen_surrogate_key(evaluator, field_list):
+ if not isinstance(field_list, list):
+ field_list = list(field_list)
+ default_null_value = '_sqlmesh_surrogate_key_null_default_'
+ expressions = []
+ for i, field in enumerate(field_list):
+ coalesce_expression = exp.Coalesce(this=exp.cast(expression=exp.
+ Column(this=field), to='TEXT'), expressions=exp.Literal.string(
+ default_null_value))
+ expressions.append(coalesce_expression)
+ if i < len(field_list) - 1:
+ expressions.append(exp.Literal.string('-'))
+ concat_exp = exp.Concat(expressions=expressions)
+ hash_exp = exp.SHA2(this=concat_exp, length=exp.Literal.number(256))
+ return hash_exp
@DEF(payment_methods, ['credit_card', 'coupon', 'bank_transfer', 'gift_card'])
WITH orders AS (
SELECT
@@ -30,6 +46,7 @@
order_id
), final AS (
SELECT
+ @gen_surrogate_key() AS surrogate_key,
orders.order_id,
orders.customer_id,
orders.order_date,
Directly Modified: demo.orders (Indirect Breaking)
Directly Modified: demo.seed_model (Non-breaking)
└── Indirectly Modified Children:
├── demo.full_model (Indirect Non-breaking)
└── demo.incremental_model (Indirect Non-breaking)
Directly Modified: demo.seed_raw_customers (Non-breaking)
└── Indirectly Modified Children:
└── demo.stg_customers (Indirect Non-breaking)
Directly Modified: demo.seed_raw_orders (Non-breaking)
└── Indirectly Modified Children:
└── demo.stg_orders (Indirect Non-breaking)
Directly Modified: demo.seed_raw_payments (Non-breaking)
---
+++
@@ -12,5 +12,6 @@
id AS payment_id,
order_id,
payment_method,
- amount / 100 AS amount
+ amount / 100 AS amount,
+ 'new_column' AS new_column
FROM demo.seed_raw_payments
Directly Modified: demo.stg_payments (Indirect Non-breaking)
Loading