Models
Pydantic models for koality configuration validation.
Config
Bases: BaseModel
Root configuration model for koality check execution.
Source code in src/koality/models.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | |
propagate_defaults_to_checks(data)
classmethod
Merge defaults and check_bundle.defaults into each check before validation.
Merge order (later overrides earlier): 1. defaults 2. bundle defaults 3. check-specific values
For the 'filters' dict, a deep merge is performed so that check-level filters override individual filter entries rather than replacing the whole dict.
Source code in src/koality/models.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
validate_filter_values_complete()
Validate that all filters in checks have column and value set.
Filters in defaults can omit column/value (to be set at check level), but after merging, all filters must have both column and value except for identifier-type filters which are allowed to omit a value (used for naming).
Source code in src/koality/models.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | |
validate_identifier_consistency()
Validate identifier filter consistency based on identifier_format.
When identifier_format is 'filter_name' or 'column_name', all identifier filters across all checks must have the same filter name or column name respectively, since these are used as result column headers. Also checks that if identifier_format is 'filter_name' or 'column_name', every check has an identifier filter.
Source code in src/koality/models.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
DatabaseProvider
dataclass
Data class representing a DuckDB database provider connection.
Source code in src/koality/models.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
FilterConfig
Bases: BaseModel
Configuration for a single filter.
Attributes:
| Name | Type | Description |
|---|---|---|
column |
str | None
|
The database column name to filter on. |
value |
FilterValue
|
The filter value (can be any type, will be converted to string in SQL). For IN/NOT IN operators, use a list of values. For date filters, supports relative dates like "today", "yesterday", and offsets like "yesterday-2" or "today+1". |
operator |
FilterOperator
|
SQL comparison operator. Defaults to "=" (equality). |
type |
FilterType
|
Filter type - "date" for date filters (used for rolling checks), "identifier" for identifier filters (e.g., shop_id), "other" for regular filters. Only one "date" and one "identifier" type filter is allowed per configuration. When type="date", the value is automatically parsed as a date. |
parse_as_date |
bool
|
If True, the value will be parsed as a date even for type="other". Useful for filters that need date parsing but aren't the primary date filter. |
Example
filters: partition_date: column: BQ_PARTITIONTIME value: yesterday-2 # 2 days before yesterday type: date shop_id: column: shopId value: EC0601 type: identifier created_at: column: created_date value: today+1 # tomorrow parse_as_date: true # parses date but doesn't count as the "date" filter revenue: column: total_revenue value: 1000 operator: ">="
Source code in src/koality/models.py
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 | |
validate_operator_value_combination()
Validate that operator and value type are compatible.
Skips validation when value is None with default operator, as this indicates a partial filter in defaults that will be completed later.
Source code in src/koality/models.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |