-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinance_transactions_data_contract.yml
More file actions
106 lines (104 loc) · 2.78 KB
/
finance_transactions_data_contract.yml
File metadata and controls
106 lines (104 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
dataset: datasource/database/schema/finance_transactions
checks:
- schema:
allow_extra_columns: false
allow_other_column_order: false
- row_count:
threshold:
must_be_greater_than: 0
- freshness:
column: transaction_timestamp
threshold:
unit: hour
must_be_less_than_or_equal: 24
- failed_rows:
name: "Transaction timestamp must not be in the future"
qualifier: ts_not_future
expression: transaction_timestamp > ${soda.NOW}
- failed_rows:
name: "Amount sign must match transaction_type (DEBIT negative, CREDIT positive)"
qualifier: amount_sign_by_type
expression: >
(transaction_type = 'DEBIT' AND amount >= 0)
OR (transaction_type = 'CREDIT' AND amount <= 0)
columns:
- name: transaction_id
data_type: varchar
checks:
- missing:
- duplicate:
- invalid:
name: "transaction_id must be a UUID"
valid_format:
name: UUID
regex: "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
- name: account_id
data_type: varchar
checks:
- missing:
- invalid:
name: "account_id must be non-empty and sane length"
valid_min_length: 1
valid_max_length: 64
- name: customer_id
data_type: varchar
checks:
- missing:
- invalid:
name: "customer_id must be non-empty and sane length"
valid_min_length: 1
valid_max_length: 64
- name: transaction_timestamp
data_type: timestamp
checks:
- missing:
- name: amount
data_type: decimal
checks:
- missing:
- invalid:
name: "Amount must not be zero (allow tiny tolerance in case of rare edge cases)"
invalid_values: [0]
threshold:
metric: percent
must_be_less_than: 0.1
- name: currency
data_type: varchar
checks:
- missing:
- invalid:
name: "Currency must be ISO-4217-like (3 uppercase letters)"
valid_format:
name: ISO-4217 code
regex: "^[A-Z]{3}$"
- name: transaction_type
data_type: varchar
checks:
- missing:
- invalid:
name: "Allowed transaction types"
valid_values:
- DEBIT
- CREDIT
- TRANSFER
- FEE
- REVERSAL
- ADJUSTMENT
- name: status
data_type: varchar
checks:
- missing:
- invalid:
name: "Allowed statuses"
valid_values:
- PENDING
- POSTED
- REVERSED
- FAILED
- CANCELLED
- name: reference_id
data_type: varchar
checks:
- invalid:
name: "reference_id length guardrail"
valid_max_length: 128