fastflowtransform.testing.base¶
TestFailure ¶
Bases: Exception
Raised when a data-quality check fails.
Source code in src/fastflowtransform/testing/base.py
162 163 164 165 166 167 | |
sql_list ¶
sql_list(values)
Render a simple SQL literal list, portable enough for DuckDB/Postgres/BigQuery.
Source code in src/fastflowtransform/testing/base.py
117 118 119 120 121 122 123 124 125 126 127 128 | |
accepted_values ¶
accepted_values(con, table, column, *, values, where=None)
Fail if any non-NULL value of table.column is outside the set 'values'.
Source code in src/fastflowtransform/testing/base.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
not_null ¶
not_null(con, table, column, where=None)
Fails if any non-filtered row has NULL in column.
Source code in src/fastflowtransform/testing/base.py
185 186 187 188 189 190 191 192 193 194 195 196 | |
unique ¶
unique(con, table, column, where=None)
Fails if any duplicate appears in column within the (optionally) filtered set.
Source code in src/fastflowtransform/testing/base.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
freshness ¶
freshness(con, table, ts_col, max_delay_minutes)
Fail if the latest timestamp in ts_col is older than max_delay_minutes.
Behaviour: - First, run a lightweight probe on max(ts_col) to detect clearly wrong types (e.g. VARCHAR) and emit an actionable error instead of an engine-specific type/binder exception. - Then compute the delay in minutes using an engine-friendly expression: * Postgres / DuckDB: date_part('epoch', now() - max(ts_col)) / 60.0 * Spark / Databricks: (unix_timestamp(current_timestamp()) - unix_timestamp(max(ts_col))) / 60.0
For Spark-like connections we go straight to the unix_timestamp variant so we do not trigger noisy INVALID_EXTRACT_FIELD logs from the planner.
Source code in src/fastflowtransform/testing/base.py
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 | |
reconcile_equal ¶
reconcile_equal(con, left, right, abs_tolerance=None, rel_tolerance_pct=None)
Assert left == right within absolute and/or relative tolerances.
Both sides are dictionaries: {"table": str, "expr": str, "where": Optional[str]}. If both tolerances are omitted, exact equality is enforced.
Source code in src/fastflowtransform/testing/base.py
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 | |
reconcile_ratio_within ¶
reconcile_ratio_within(con, left, right, min_ratio, max_ratio)
Assert min_ratio <= (left/right) <= max_ratio.
Source code in src/fastflowtransform/testing/base.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | |
reconcile_diff_within ¶
reconcile_diff_within(con, left, right, max_abs_diff)
Assert |left - right| <= max_abs_diff.
Source code in src/fastflowtransform/testing/base.py
494 495 496 497 498 499 500 501 502 | |
reconcile_coverage ¶
reconcile_coverage(con, source, target, source_where=None, target_where=None)
Assert that every key from source exists in target (anti-join count == 0).
Source code in src/fastflowtransform/testing/base.py
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
relationships ¶
relationships(con, table, field, to_table, to_field, *, where=None, to_where=None)
Assert that every value from child table.field exists in parent to_table.to_field.
Implemented as an anti-join count; failures report the number of missing keys.
Source code in src/fastflowtransform/testing/base.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |