feat(dataflow): model production SQL flow patterns
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"nodes": [
|
||||
{
|
||||
"id": "bookings",
|
||||
"type": "source.inline",
|
||||
"label": "Bookings",
|
||||
"position": {"x": 40, "y": 120},
|
||||
"config": {
|
||||
"source_name": "bookings",
|
||||
"fixture": "bookings.json",
|
||||
"rows": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "booking-calculations",
|
||||
"type": "calculate",
|
||||
"label": "Normalize and classify",
|
||||
"position": {"x": 280, "y": 120},
|
||||
"config": {
|
||||
"calculations": [
|
||||
{
|
||||
"target_column": "cost_center",
|
||||
"expression": "cast(trim(cost_text) as integer)",
|
||||
"result_type": "integer"
|
||||
},
|
||||
{
|
||||
"target_column": "period",
|
||||
"expression": "to_char(booking_date, 'YYYY/MM')",
|
||||
"result_type": "string"
|
||||
},
|
||||
{
|
||||
"target_column": "booking_class",
|
||||
"expression": "case when cost_center between 62000 and 65999 then 'personnel' when cost_center between 97000000 and 97999999 then 'allocation' else 'other' end",
|
||||
"result_type": "string"
|
||||
},
|
||||
{
|
||||
"target_column": "signed_amount",
|
||||
"expression": "case when entry_type = 'credit' then 0 - amount else amount end",
|
||||
"result_type": "integer"
|
||||
},
|
||||
{
|
||||
"target_column": "record_key",
|
||||
"expression": "lpad(cast(sequence as text), 6, '0')",
|
||||
"result_type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "required-fields",
|
||||
"type": "quality.rules",
|
||||
"label": "Required booking fields",
|
||||
"position": {"x": 520, "y": 120},
|
||||
"config": {
|
||||
"rules": [
|
||||
{"id": "cost-center", "column": "cost_center", "operator": "not_null"},
|
||||
{"id": "period", "column": "period", "operator": "not_null"},
|
||||
{"id": "amount", "column": "signed_amount", "operator": "not_null"}
|
||||
],
|
||||
"action": "fail"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "booking-summary",
|
||||
"type": "aggregate",
|
||||
"label": "Monthly booking summary",
|
||||
"position": {"x": 760, "y": 120},
|
||||
"config": {
|
||||
"group_by": ["period", "booking_class"],
|
||||
"aggregates": [
|
||||
{"function": "count", "column": "*", "alias": "booking_count"},
|
||||
{"function": "sum", "column": "signed_amount", "alias": "net_amount"}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "summary-order",
|
||||
"type": "sort",
|
||||
"label": "Order summary",
|
||||
"position": {"x": 1000, "y": 120},
|
||||
"config": {
|
||||
"fields": [
|
||||
{"column": "period", "direction": "asc"},
|
||||
{"column": "booking_class", "direction": "asc"}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "output",
|
||||
"type": "output",
|
||||
"label": "Booking summary",
|
||||
"position": {"x": 1240, "y": 120},
|
||||
"config": {}
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{"id": "e1", "source": "bookings", "target": "booking-calculations"},
|
||||
{"id": "e2", "source": "booking-calculations", "target": "required-fields"},
|
||||
{"id": "e3", "source": "required-fields", "target": "booking-summary"},
|
||||
{"id": "e4", "source": "booking-summary", "target": "summary-order"},
|
||||
{"id": "e5", "source": "summary-order", "target": "output"}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user