truthound-dashboard 1.2.1__py3-none-any.whl → 1.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- truthound_dashboard/api/deps.py +28 -0
- truthound_dashboard/api/drift.py +1 -0
- truthound_dashboard/api/mask.py +164 -0
- truthound_dashboard/api/profile.py +11 -3
- truthound_dashboard/api/router.py +22 -0
- truthound_dashboard/api/scan.py +168 -0
- truthound_dashboard/api/schemas.py +13 -4
- truthound_dashboard/api/validations.py +33 -1
- truthound_dashboard/api/validators.py +85 -0
- truthound_dashboard/core/__init__.py +8 -0
- truthound_dashboard/core/phase5/activity.py +1 -1
- truthound_dashboard/core/services.py +457 -7
- truthound_dashboard/core/truthound_adapter.py +441 -26
- truthound_dashboard/db/__init__.py +6 -0
- truthound_dashboard/db/models.py +250 -1
- truthound_dashboard/schemas/__init__.py +52 -1
- truthound_dashboard/schemas/collaboration.py +1 -1
- truthound_dashboard/schemas/drift.py +118 -3
- truthound_dashboard/schemas/mask.py +209 -0
- truthound_dashboard/schemas/profile.py +45 -2
- truthound_dashboard/schemas/scan.py +312 -0
- truthound_dashboard/schemas/schema.py +30 -2
- truthound_dashboard/schemas/validation.py +60 -3
- truthound_dashboard/schemas/validators/__init__.py +59 -0
- truthound_dashboard/schemas/validators/aggregate_validators.py +238 -0
- truthound_dashboard/schemas/validators/anomaly_validators.py +723 -0
- truthound_dashboard/schemas/validators/base.py +263 -0
- truthound_dashboard/schemas/validators/completeness_validators.py +269 -0
- truthound_dashboard/schemas/validators/cross_table_validators.py +375 -0
- truthound_dashboard/schemas/validators/datetime_validators.py +253 -0
- truthound_dashboard/schemas/validators/distribution_validators.py +422 -0
- truthound_dashboard/schemas/validators/drift_validators.py +615 -0
- truthound_dashboard/schemas/validators/geospatial_validators.py +486 -0
- truthound_dashboard/schemas/validators/multi_column_validators.py +706 -0
- truthound_dashboard/schemas/validators/privacy_validators.py +531 -0
- truthound_dashboard/schemas/validators/query_validators.py +510 -0
- truthound_dashboard/schemas/validators/registry.py +318 -0
- truthound_dashboard/schemas/validators/schema_validators.py +408 -0
- truthound_dashboard/schemas/validators/string_validators.py +396 -0
- truthound_dashboard/schemas/validators/table_validators.py +412 -0
- truthound_dashboard/schemas/validators/uniqueness_validators.py +355 -0
- truthound_dashboard/schemas/validators.py +59 -0
- truthound_dashboard/static/assets/{index-BqXVFyqj.js → index-BCA8H1hO.js} +95 -95
- truthound_dashboard/static/assets/index-BNsSQ2fN.css +1 -0
- truthound_dashboard/static/assets/unmerged_dictionaries-CsJWCRx9.js +1 -0
- truthound_dashboard/static/index.html +2 -2
- {truthound_dashboard-1.2.1.dist-info → truthound_dashboard-1.3.0.dist-info}/METADATA +46 -11
- {truthound_dashboard-1.2.1.dist-info → truthound_dashboard-1.3.0.dist-info}/RECORD +51 -27
- truthound_dashboard/static/assets/index-o8qHVDte.css +0 -1
- truthound_dashboard/static/assets/unmerged_dictionaries-n_T3wZTf.js +0 -1
- {truthound_dashboard-1.2.1.dist-info → truthound_dashboard-1.3.0.dist-info}/WHEEL +0 -0
- {truthound_dashboard-1.2.1.dist-info → truthound_dashboard-1.3.0.dist-info}/entry_points.txt +0 -0
- {truthound_dashboard-1.2.1.dist-info → truthound_dashboard-1.3.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
"""Query validators.
|
|
2
|
+
|
|
3
|
+
Expression-based validators using Polars expressions and custom queries.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .base import (
|
|
7
|
+
ParameterDefinition,
|
|
8
|
+
ParameterType,
|
|
9
|
+
ValidatorCategory,
|
|
10
|
+
ValidatorDefinition,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
QUERY_VALIDATORS: list[ValidatorDefinition] = [
|
|
14
|
+
ValidatorDefinition(
|
|
15
|
+
name="Expression",
|
|
16
|
+
display_name="Expression Validator",
|
|
17
|
+
category=ValidatorCategory.QUERY,
|
|
18
|
+
description="Validates data using a custom Polars expression.",
|
|
19
|
+
parameters=[
|
|
20
|
+
ParameterDefinition(
|
|
21
|
+
name="expression",
|
|
22
|
+
label="Expression",
|
|
23
|
+
type=ParameterType.EXPRESSION,
|
|
24
|
+
description="Polars expression that should evaluate to true",
|
|
25
|
+
required=True,
|
|
26
|
+
placeholder='col("price") > 0',
|
|
27
|
+
),
|
|
28
|
+
ParameterDefinition(
|
|
29
|
+
name="description",
|
|
30
|
+
label="Description",
|
|
31
|
+
type=ParameterType.STRING,
|
|
32
|
+
description="Human-readable description of the rule",
|
|
33
|
+
),
|
|
34
|
+
],
|
|
35
|
+
tags=["query", "expression", "custom"],
|
|
36
|
+
severity_default="medium",
|
|
37
|
+
),
|
|
38
|
+
ValidatorDefinition(
|
|
39
|
+
name="CustomExpression",
|
|
40
|
+
display_name="Custom Expression String",
|
|
41
|
+
category=ValidatorCategory.QUERY,
|
|
42
|
+
description="Validates using a Polars expression string.",
|
|
43
|
+
parameters=[
|
|
44
|
+
ParameterDefinition(
|
|
45
|
+
name="expression_str",
|
|
46
|
+
label="Expression String",
|
|
47
|
+
type=ParameterType.STRING,
|
|
48
|
+
description="Expression as string (parsed at runtime)",
|
|
49
|
+
required=True,
|
|
50
|
+
placeholder='(col("quantity") * col("price")).alias("total") == col("total")',
|
|
51
|
+
),
|
|
52
|
+
],
|
|
53
|
+
tags=["query", "expression", "string"],
|
|
54
|
+
severity_default="medium",
|
|
55
|
+
),
|
|
56
|
+
ValidatorDefinition(
|
|
57
|
+
name="QueryRowCount",
|
|
58
|
+
display_name="Query Row Count",
|
|
59
|
+
category=ValidatorCategory.QUERY,
|
|
60
|
+
description="Validates row count from a filter query.",
|
|
61
|
+
parameters=[
|
|
62
|
+
ParameterDefinition(
|
|
63
|
+
name="filter_expression",
|
|
64
|
+
label="Filter Expression",
|
|
65
|
+
type=ParameterType.EXPRESSION,
|
|
66
|
+
description="Filter to apply before counting",
|
|
67
|
+
required=True,
|
|
68
|
+
placeholder='col("status") == "error"',
|
|
69
|
+
),
|
|
70
|
+
ParameterDefinition(
|
|
71
|
+
name="expected_count",
|
|
72
|
+
label="Expected Count",
|
|
73
|
+
type=ParameterType.INTEGER,
|
|
74
|
+
min_value=0,
|
|
75
|
+
),
|
|
76
|
+
ParameterDefinition(
|
|
77
|
+
name="max_count",
|
|
78
|
+
label="Maximum Count",
|
|
79
|
+
type=ParameterType.INTEGER,
|
|
80
|
+
min_value=0,
|
|
81
|
+
),
|
|
82
|
+
],
|
|
83
|
+
tags=["query", "count", "filter"],
|
|
84
|
+
severity_default="medium",
|
|
85
|
+
),
|
|
86
|
+
ValidatorDefinition(
|
|
87
|
+
name="QueryReturnsNoRows",
|
|
88
|
+
display_name="Query Returns No Rows",
|
|
89
|
+
category=ValidatorCategory.QUERY,
|
|
90
|
+
description="Validates that a filter query returns zero rows (no violations).",
|
|
91
|
+
parameters=[
|
|
92
|
+
ParameterDefinition(
|
|
93
|
+
name="filter_expression",
|
|
94
|
+
label="Violation Filter",
|
|
95
|
+
type=ParameterType.EXPRESSION,
|
|
96
|
+
description="Filter that should match zero rows",
|
|
97
|
+
required=True,
|
|
98
|
+
placeholder='(col("start_date") > col("end_date"))',
|
|
99
|
+
),
|
|
100
|
+
ParameterDefinition(
|
|
101
|
+
name="violation_message",
|
|
102
|
+
label="Violation Message",
|
|
103
|
+
type=ParameterType.STRING,
|
|
104
|
+
description="Message to show when violations found",
|
|
105
|
+
),
|
|
106
|
+
],
|
|
107
|
+
tags=["query", "no_rows", "violation"],
|
|
108
|
+
severity_default="high",
|
|
109
|
+
),
|
|
110
|
+
ValidatorDefinition(
|
|
111
|
+
name="QueryReturnsRows",
|
|
112
|
+
display_name="Query Returns Rows",
|
|
113
|
+
category=ValidatorCategory.QUERY,
|
|
114
|
+
description="Validates that a filter query returns at least one row.",
|
|
115
|
+
parameters=[
|
|
116
|
+
ParameterDefinition(
|
|
117
|
+
name="filter_expression",
|
|
118
|
+
label="Filter Expression",
|
|
119
|
+
type=ParameterType.EXPRESSION,
|
|
120
|
+
description="Filter that should match at least one row",
|
|
121
|
+
required=True,
|
|
122
|
+
),
|
|
123
|
+
ParameterDefinition(
|
|
124
|
+
name="min_rows",
|
|
125
|
+
label="Minimum Rows",
|
|
126
|
+
type=ParameterType.INTEGER,
|
|
127
|
+
default=1,
|
|
128
|
+
min_value=1,
|
|
129
|
+
),
|
|
130
|
+
],
|
|
131
|
+
tags=["query", "rows", "existence"],
|
|
132
|
+
severity_default="medium",
|
|
133
|
+
),
|
|
134
|
+
ValidatorDefinition(
|
|
135
|
+
name="QueryAggregate",
|
|
136
|
+
display_name="Query Aggregate",
|
|
137
|
+
category=ValidatorCategory.QUERY,
|
|
138
|
+
description="Validates aggregate result from a query.",
|
|
139
|
+
parameters=[
|
|
140
|
+
ParameterDefinition(
|
|
141
|
+
name="column",
|
|
142
|
+
label="Column",
|
|
143
|
+
type=ParameterType.COLUMN,
|
|
144
|
+
required=True,
|
|
145
|
+
),
|
|
146
|
+
ParameterDefinition(
|
|
147
|
+
name="aggregate",
|
|
148
|
+
label="Aggregate Function",
|
|
149
|
+
type=ParameterType.SELECT,
|
|
150
|
+
required=True,
|
|
151
|
+
options=[
|
|
152
|
+
{"value": "sum", "label": "Sum"},
|
|
153
|
+
{"value": "mean", "label": "Mean"},
|
|
154
|
+
{"value": "min", "label": "Min"},
|
|
155
|
+
{"value": "max", "label": "Max"},
|
|
156
|
+
{"value": "count", "label": "Count"},
|
|
157
|
+
{"value": "std", "label": "Std Dev"},
|
|
158
|
+
],
|
|
159
|
+
),
|
|
160
|
+
ParameterDefinition(
|
|
161
|
+
name="filter_expression",
|
|
162
|
+
label="Filter Expression",
|
|
163
|
+
type=ParameterType.EXPRESSION,
|
|
164
|
+
description="Optional filter before aggregation",
|
|
165
|
+
),
|
|
166
|
+
ParameterDefinition(
|
|
167
|
+
name="expected_value",
|
|
168
|
+
label="Expected Value",
|
|
169
|
+
type=ParameterType.FLOAT,
|
|
170
|
+
),
|
|
171
|
+
ParameterDefinition(
|
|
172
|
+
name="min_value",
|
|
173
|
+
label="Minimum Value",
|
|
174
|
+
type=ParameterType.FLOAT,
|
|
175
|
+
),
|
|
176
|
+
ParameterDefinition(
|
|
177
|
+
name="max_value",
|
|
178
|
+
label="Maximum Value",
|
|
179
|
+
type=ParameterType.FLOAT,
|
|
180
|
+
),
|
|
181
|
+
ParameterDefinition(
|
|
182
|
+
name="tolerance",
|
|
183
|
+
label="Tolerance",
|
|
184
|
+
type=ParameterType.FLOAT,
|
|
185
|
+
default=0.0001,
|
|
186
|
+
min_value=0,
|
|
187
|
+
),
|
|
188
|
+
],
|
|
189
|
+
tags=["query", "aggregate", "statistics"],
|
|
190
|
+
severity_default="medium",
|
|
191
|
+
),
|
|
192
|
+
ValidatorDefinition(
|
|
193
|
+
name="QueryGroupAggregate",
|
|
194
|
+
display_name="Query Group Aggregate",
|
|
195
|
+
category=ValidatorCategory.QUERY,
|
|
196
|
+
description="Validates aggregate per group.",
|
|
197
|
+
parameters=[
|
|
198
|
+
ParameterDefinition(
|
|
199
|
+
name="column",
|
|
200
|
+
label="Column to Aggregate",
|
|
201
|
+
type=ParameterType.COLUMN,
|
|
202
|
+
required=True,
|
|
203
|
+
),
|
|
204
|
+
ParameterDefinition(
|
|
205
|
+
name="group_by",
|
|
206
|
+
label="Group By Columns",
|
|
207
|
+
type=ParameterType.COLUMN_LIST,
|
|
208
|
+
required=True,
|
|
209
|
+
),
|
|
210
|
+
ParameterDefinition(
|
|
211
|
+
name="aggregate",
|
|
212
|
+
label="Aggregate Function",
|
|
213
|
+
type=ParameterType.SELECT,
|
|
214
|
+
required=True,
|
|
215
|
+
options=[
|
|
216
|
+
{"value": "sum", "label": "Sum"},
|
|
217
|
+
{"value": "mean", "label": "Mean"},
|
|
218
|
+
{"value": "min", "label": "Min"},
|
|
219
|
+
{"value": "max", "label": "Max"},
|
|
220
|
+
{"value": "count", "label": "Count"},
|
|
221
|
+
],
|
|
222
|
+
),
|
|
223
|
+
ParameterDefinition(
|
|
224
|
+
name="min_value",
|
|
225
|
+
label="Min Value Per Group",
|
|
226
|
+
type=ParameterType.FLOAT,
|
|
227
|
+
),
|
|
228
|
+
ParameterDefinition(
|
|
229
|
+
name="max_value",
|
|
230
|
+
label="Max Value Per Group",
|
|
231
|
+
type=ParameterType.FLOAT,
|
|
232
|
+
),
|
|
233
|
+
],
|
|
234
|
+
tags=["query", "group", "aggregate"],
|
|
235
|
+
severity_default="medium",
|
|
236
|
+
),
|
|
237
|
+
ValidatorDefinition(
|
|
238
|
+
name="QueryAggregateCompare",
|
|
239
|
+
display_name="Query Aggregate Compare",
|
|
240
|
+
category=ValidatorCategory.QUERY,
|
|
241
|
+
description="Compares aggregates from two different filters.",
|
|
242
|
+
parameters=[
|
|
243
|
+
ParameterDefinition(
|
|
244
|
+
name="column",
|
|
245
|
+
label="Column",
|
|
246
|
+
type=ParameterType.COLUMN,
|
|
247
|
+
required=True,
|
|
248
|
+
),
|
|
249
|
+
ParameterDefinition(
|
|
250
|
+
name="filter_a",
|
|
251
|
+
label="Filter A",
|
|
252
|
+
type=ParameterType.EXPRESSION,
|
|
253
|
+
required=True,
|
|
254
|
+
),
|
|
255
|
+
ParameterDefinition(
|
|
256
|
+
name="filter_b",
|
|
257
|
+
label="Filter B",
|
|
258
|
+
type=ParameterType.EXPRESSION,
|
|
259
|
+
required=True,
|
|
260
|
+
),
|
|
261
|
+
ParameterDefinition(
|
|
262
|
+
name="aggregate",
|
|
263
|
+
label="Aggregate Function",
|
|
264
|
+
type=ParameterType.SELECT,
|
|
265
|
+
required=True,
|
|
266
|
+
options=[
|
|
267
|
+
{"value": "sum", "label": "Sum"},
|
|
268
|
+
{"value": "mean", "label": "Mean"},
|
|
269
|
+
{"value": "count", "label": "Count"},
|
|
270
|
+
],
|
|
271
|
+
),
|
|
272
|
+
ParameterDefinition(
|
|
273
|
+
name="operator",
|
|
274
|
+
label="Comparison",
|
|
275
|
+
type=ParameterType.SELECT,
|
|
276
|
+
required=True,
|
|
277
|
+
options=[
|
|
278
|
+
{"value": "eq", "label": "A = B"},
|
|
279
|
+
{"value": "gt", "label": "A > B"},
|
|
280
|
+
{"value": "gte", "label": "A >= B"},
|
|
281
|
+
{"value": "lt", "label": "A < B"},
|
|
282
|
+
{"value": "lte", "label": "A <= B"},
|
|
283
|
+
],
|
|
284
|
+
),
|
|
285
|
+
ParameterDefinition(
|
|
286
|
+
name="tolerance",
|
|
287
|
+
label="Tolerance",
|
|
288
|
+
type=ParameterType.FLOAT,
|
|
289
|
+
default=0.0001,
|
|
290
|
+
min_value=0,
|
|
291
|
+
),
|
|
292
|
+
],
|
|
293
|
+
tags=["query", "compare", "aggregate"],
|
|
294
|
+
severity_default="medium",
|
|
295
|
+
),
|
|
296
|
+
ValidatorDefinition(
|
|
297
|
+
name="QueryColumnValues",
|
|
298
|
+
display_name="Query Column Values",
|
|
299
|
+
category=ValidatorCategory.QUERY,
|
|
300
|
+
description="Validates column values from filtered query.",
|
|
301
|
+
parameters=[
|
|
302
|
+
ParameterDefinition(
|
|
303
|
+
name="column",
|
|
304
|
+
label="Column",
|
|
305
|
+
type=ParameterType.COLUMN,
|
|
306
|
+
required=True,
|
|
307
|
+
),
|
|
308
|
+
ParameterDefinition(
|
|
309
|
+
name="filter_expression",
|
|
310
|
+
label="Filter Expression",
|
|
311
|
+
type=ParameterType.EXPRESSION,
|
|
312
|
+
),
|
|
313
|
+
ParameterDefinition(
|
|
314
|
+
name="expected_values",
|
|
315
|
+
label="Expected Values",
|
|
316
|
+
type=ParameterType.STRING_LIST,
|
|
317
|
+
description="Values that should appear",
|
|
318
|
+
),
|
|
319
|
+
ParameterDefinition(
|
|
320
|
+
name="forbidden_values",
|
|
321
|
+
label="Forbidden Values",
|
|
322
|
+
type=ParameterType.STRING_LIST,
|
|
323
|
+
description="Values that should not appear",
|
|
324
|
+
),
|
|
325
|
+
],
|
|
326
|
+
tags=["query", "values", "column"],
|
|
327
|
+
severity_default="medium",
|
|
328
|
+
),
|
|
329
|
+
ValidatorDefinition(
|
|
330
|
+
name="QueryColumnUnique",
|
|
331
|
+
display_name="Query Column Unique",
|
|
332
|
+
category=ValidatorCategory.QUERY,
|
|
333
|
+
description="Validates uniqueness within filtered results.",
|
|
334
|
+
parameters=[
|
|
335
|
+
ParameterDefinition(
|
|
336
|
+
name="column",
|
|
337
|
+
label="Column",
|
|
338
|
+
type=ParameterType.COLUMN,
|
|
339
|
+
required=True,
|
|
340
|
+
),
|
|
341
|
+
ParameterDefinition(
|
|
342
|
+
name="filter_expression",
|
|
343
|
+
label="Filter Expression",
|
|
344
|
+
type=ParameterType.EXPRESSION,
|
|
345
|
+
),
|
|
346
|
+
],
|
|
347
|
+
tags=["query", "unique", "filter"],
|
|
348
|
+
severity_default="high",
|
|
349
|
+
),
|
|
350
|
+
ValidatorDefinition(
|
|
351
|
+
name="QueryColumnNotNull",
|
|
352
|
+
display_name="Query Column Not Null",
|
|
353
|
+
category=ValidatorCategory.QUERY,
|
|
354
|
+
description="Validates no nulls within filtered results.",
|
|
355
|
+
parameters=[
|
|
356
|
+
ParameterDefinition(
|
|
357
|
+
name="column",
|
|
358
|
+
label="Column",
|
|
359
|
+
type=ParameterType.COLUMN,
|
|
360
|
+
required=True,
|
|
361
|
+
),
|
|
362
|
+
ParameterDefinition(
|
|
363
|
+
name="filter_expression",
|
|
364
|
+
label="Filter Expression",
|
|
365
|
+
type=ParameterType.EXPRESSION,
|
|
366
|
+
),
|
|
367
|
+
],
|
|
368
|
+
tags=["query", "not_null", "filter"],
|
|
369
|
+
severity_default="high",
|
|
370
|
+
),
|
|
371
|
+
ValidatorDefinition(
|
|
372
|
+
name="ConditionalExpression",
|
|
373
|
+
display_name="Conditional Expression",
|
|
374
|
+
category=ValidatorCategory.QUERY,
|
|
375
|
+
description="Validates expression only when condition is met.",
|
|
376
|
+
parameters=[
|
|
377
|
+
ParameterDefinition(
|
|
378
|
+
name="condition",
|
|
379
|
+
label="Condition",
|
|
380
|
+
type=ParameterType.EXPRESSION,
|
|
381
|
+
description="When this is true, validate the expression",
|
|
382
|
+
required=True,
|
|
383
|
+
),
|
|
384
|
+
ParameterDefinition(
|
|
385
|
+
name="expression",
|
|
386
|
+
label="Expression",
|
|
387
|
+
type=ParameterType.EXPRESSION,
|
|
388
|
+
description="Expression to validate when condition is met",
|
|
389
|
+
required=True,
|
|
390
|
+
),
|
|
391
|
+
],
|
|
392
|
+
tags=["query", "conditional", "expression"],
|
|
393
|
+
severity_default="medium",
|
|
394
|
+
),
|
|
395
|
+
ValidatorDefinition(
|
|
396
|
+
name="MultiCondition",
|
|
397
|
+
display_name="Multi-Condition Validator",
|
|
398
|
+
category=ValidatorCategory.QUERY,
|
|
399
|
+
description="Validates multiple conditions simultaneously.",
|
|
400
|
+
parameters=[
|
|
401
|
+
ParameterDefinition(
|
|
402
|
+
name="conditions",
|
|
403
|
+
label="Conditions",
|
|
404
|
+
type=ParameterType.STRING_LIST,
|
|
405
|
+
description="List of condition expressions (all must pass)",
|
|
406
|
+
required=True,
|
|
407
|
+
),
|
|
408
|
+
ParameterDefinition(
|
|
409
|
+
name="mode",
|
|
410
|
+
label="Mode",
|
|
411
|
+
type=ParameterType.SELECT,
|
|
412
|
+
options=[
|
|
413
|
+
{"value": "all", "label": "All must pass"},
|
|
414
|
+
{"value": "any", "label": "Any must pass"},
|
|
415
|
+
{"value": "none", "label": "None should pass"},
|
|
416
|
+
],
|
|
417
|
+
default="all",
|
|
418
|
+
),
|
|
419
|
+
],
|
|
420
|
+
tags=["query", "multi", "conditions"],
|
|
421
|
+
severity_default="medium",
|
|
422
|
+
),
|
|
423
|
+
ValidatorDefinition(
|
|
424
|
+
name="RowLevel",
|
|
425
|
+
display_name="Row-Level Validator",
|
|
426
|
+
category=ValidatorCategory.QUERY,
|
|
427
|
+
description="Validates expression at the row level.",
|
|
428
|
+
parameters=[
|
|
429
|
+
ParameterDefinition(
|
|
430
|
+
name="expression",
|
|
431
|
+
label="Row Expression",
|
|
432
|
+
type=ParameterType.EXPRESSION,
|
|
433
|
+
description="Expression evaluated per row",
|
|
434
|
+
required=True,
|
|
435
|
+
),
|
|
436
|
+
ParameterDefinition(
|
|
437
|
+
name="min_pass_ratio",
|
|
438
|
+
label="Min Pass Ratio",
|
|
439
|
+
type=ParameterType.FLOAT,
|
|
440
|
+
description="Minimum ratio of rows that must pass",
|
|
441
|
+
default=1.0,
|
|
442
|
+
min_value=0,
|
|
443
|
+
max_value=1,
|
|
444
|
+
),
|
|
445
|
+
],
|
|
446
|
+
tags=["query", "row", "per_row"],
|
|
447
|
+
severity_default="medium",
|
|
448
|
+
),
|
|
449
|
+
ValidatorDefinition(
|
|
450
|
+
name="SQLQuery",
|
|
451
|
+
display_name="SQL Query Validator",
|
|
452
|
+
category=ValidatorCategory.QUERY,
|
|
453
|
+
description="Validates data using SQL query syntax.",
|
|
454
|
+
parameters=[
|
|
455
|
+
ParameterDefinition(
|
|
456
|
+
name="query",
|
|
457
|
+
label="SQL Query",
|
|
458
|
+
type=ParameterType.STRING,
|
|
459
|
+
description="SQL query (using Polars SQL context)",
|
|
460
|
+
required=True,
|
|
461
|
+
placeholder="SELECT * FROM df WHERE price < 0",
|
|
462
|
+
),
|
|
463
|
+
ParameterDefinition(
|
|
464
|
+
name="expect_empty",
|
|
465
|
+
label="Expect Empty Result",
|
|
466
|
+
type=ParameterType.BOOLEAN,
|
|
467
|
+
description="Query should return no rows (violations)",
|
|
468
|
+
default=True,
|
|
469
|
+
),
|
|
470
|
+
],
|
|
471
|
+
tags=["query", "sql", "advanced"],
|
|
472
|
+
severity_default="medium",
|
|
473
|
+
),
|
|
474
|
+
ValidatorDefinition(
|
|
475
|
+
name="BusinessRule",
|
|
476
|
+
display_name="Business Rule Validator",
|
|
477
|
+
category=ValidatorCategory.QUERY,
|
|
478
|
+
description="Validates complex business rules using expressions.",
|
|
479
|
+
parameters=[
|
|
480
|
+
ParameterDefinition(
|
|
481
|
+
name="rule_name",
|
|
482
|
+
label="Rule Name",
|
|
483
|
+
type=ParameterType.STRING,
|
|
484
|
+
description="Name of the business rule",
|
|
485
|
+
required=True,
|
|
486
|
+
),
|
|
487
|
+
ParameterDefinition(
|
|
488
|
+
name="rule_expression",
|
|
489
|
+
label="Rule Expression",
|
|
490
|
+
type=ParameterType.EXPRESSION,
|
|
491
|
+
description="Expression that defines the rule",
|
|
492
|
+
required=True,
|
|
493
|
+
),
|
|
494
|
+
ParameterDefinition(
|
|
495
|
+
name="error_message",
|
|
496
|
+
label="Error Message",
|
|
497
|
+
type=ParameterType.STRING,
|
|
498
|
+
description="Message when rule is violated",
|
|
499
|
+
),
|
|
500
|
+
ParameterDefinition(
|
|
501
|
+
name="category",
|
|
502
|
+
label="Rule Category",
|
|
503
|
+
type=ParameterType.STRING,
|
|
504
|
+
description="Business category (e.g., finance, compliance)",
|
|
505
|
+
),
|
|
506
|
+
],
|
|
507
|
+
tags=["query", "business", "rule"],
|
|
508
|
+
severity_default="high",
|
|
509
|
+
),
|
|
510
|
+
]
|