API Reference
The building blocks of Veridelta. Explore the configuration schemas, core diffing engine, and operational utilities.
Configuration Models
Strict Pydantic models defining how Veridelta comparisons are structured. These can be instantiated programmatically or driven by declarative YAML.
Data models for Veridelta configuration and results.
This module defines the Pydantic models used to configure data ingestion, comparison rules, and format the output summaries. It acts as the strict schema definition for the YAML configuration files.
SchemaMode = Literal['exact', 'allow_additions', 'allow_removals', 'intersection']
module-attribute
Defines how strictly the engine enforces column schemas between datasets.
"exact": Strict 1:1 mapping. Columns must be identical and in the exact same order."allow_additions": Target can have new columns, but must contain every column present in the Source."allow_removals": Target is allowed to drop legacy columns, but cannot add any new columns."intersection": Only diff columns that exist in both datasets, ignoring all others. (Default)
SourceType = Literal['csv', 'json', 'parquet', 'fixed_width', 'netcdf', 'shapefile', 'geopackage', 'excel', 'sql', 'delta', 'avro', 'xml', 'arrow']
module-attribute
Supported and roadmap data formats for ingestion.
WhitespaceMode = Literal['none', 'left', 'right', 'both']
module-attribute
Granular control over string whitespace stripping.
"none": Do not strip any whitespace."left": Strip leading whitespace only."right": Strip trailing whitespace only."both": Strip both leading and trailing whitespace.
DiffConfig
Bases: BaseModel
The master configuration for a Veridelta comparison run.
Attributes:
| Name | Type | Description |
|---|---|---|
primary_keys |
list[str]
|
Columns used to join and align the datasets. Must be unique in both datasets. |
schema_mode |
SchemaMode
|
How strictly to enforce column existence and matching between sources. |
strict_types |
bool
|
If False (default), the engine implicitly soft-casts target columns to source types purely for the comparison expression, preventing execution crashes on type mismatches. If True, type mismatches will automatically evaluate as row failures. |
normalize_column_names |
bool
|
If True, strips whitespace and lowercases all column headers prior to schema alignment. |
default_absolute_tolerance |
float
|
Global absolute tolerance for numeric columns. |
default_relative_tolerance |
float
|
Global relative tolerance for numeric columns. |
default_treat_null_as_equal |
bool
|
Global setting for handling NULL == NULL. |
default_whitespace_mode |
WhitespaceMode
|
Global string whitespace stripping mode. |
default_null_values |
list[str]
|
Global list of string values to aggressively coerce to NULL. |
rules |
list[DiffRule]
|
List of per-column comparison overrides. Specific
|
threshold |
float
|
Allowed mismatch ratio (0.0 to 1.0) before the |
report_top_columns_limit |
int
|
Max number of drifted columns to display in the generated markdown report summary. |
output_path |
str | None
|
Optional path to save the resulting diff report and artifacts (added, removed, and changed rows). |
output_format |
str
|
The file format for exported discrepancy artifacts (e.g., 'parquet', 'csv'). |
Source code in src/veridelta/models.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
apply_schema_normalization()
Automatically lowercases and strips config keys if normalization is enabled.
Returns:
| Name | Type | Description |
|---|---|---|
DiffConfig |
DiffConfig
|
The mutated configuration instance. |
Source code in src/veridelta/models.py
DiffRule
Bases: BaseModel
Specific overrides for one or more columns using exact names or regex.
Attributes:
| Name | Type | Description |
|---|---|---|
column_names |
list[str]
|
Exact names of the columns in the source dataset. |
pattern |
str | None
|
Regex pattern to match multiple columns (e.g., '^AMT_.*'). |
absolute_tolerance |
float | None
|
The maximum allowed absolute difference for numeric mathematical comparisons. |
relative_tolerance |
float | None
|
The maximum allowed relative difference (e.g., 0.01 for 1%). |
case_insensitive |
bool | None
|
If True, ignores case differences in strings. |
whitespace_mode |
WhitespaceMode | None
|
Granular control over stripping leading/trailing whitespace prior to string comparison. |
regex_replace |
dict[str, str] | None
|
Dictionary of |
pad_zeros |
int | None
|
Left-pad numeric strings to this exact length (e.g., 5 -> '00123'). |
value_map |
dict[str, str] | None
|
Translate Source values to Target values
before comparison (e.g., |
null_values |
list[str] | None
|
Specific string values to actively coerce
to NULL (e.g., |
treat_null_as_equal |
bool | None
|
If True, evaluates NULL == NULL as a successful match rather than a missing value mismatch. |
datetime_format |
str | None
|
Expected strptime format for dates (e.g., '%Y-%m-%d %H:%M:%S'). |
timezone |
str | None
|
Target timezone to normalize dates to before comparison. |
cast_to |
str | None
|
Explicitly cast column to this Polars datatype (e.g., 'Float64'). Evaluated after string transformations. |
ignore |
bool
|
Whether to skip this column entirely during comparison. |
rename_to |
str | None
|
The name in the target dataset if it differs from
the source. Only valid when |
Source code in src/veridelta/models.py
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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
validate_pattern(v)
classmethod
Ensures the provided regex pattern is a valid expression at configuration time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str | None
|
The string regex pattern to validate. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The validated regex string. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the regex pattern cannot be compiled. |
Source code in src/veridelta/models.py
validate_regex_replace(v)
classmethod
Ensures all keys in the regex replacement dictionary are valid regex patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
dict[str, str] | None
|
A mapping of regex patterns to replacements. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str] | None
|
dict[str, str] | None: The validated dictionary. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any key in the dictionary is an invalid regex pattern. |
Source code in src/veridelta/models.py
DiffSummary
Bases: BaseModel
The high-level execution results of a Veridelta comparison.
Attributes:
| Name | Type | Description |
|---|---|---|
total_rows_source |
int
|
Number of rows in the source dataset. |
total_rows_target |
int
|
Number of rows in the target dataset. |
added_count |
int
|
Rows found only in the target (missing from source). |
removed_count |
int
|
Rows found only in the source (missing from target). |
changed_count |
int
|
Rows present in both datasets but with value differences. |
column_mismatches |
dict[str, int]
|
Dictionary mapping column names to the exact count of mismatched rows for that specific column. |
is_match |
bool
|
Boolean indicating if the overall diff falls within the allowed mismatch threshold. |
total_mismatches |
int
|
(Computed) The sum of all added, removed, and changed rows. |
mismatch_ratio |
float
|
(Computed) The ratio of mismatched rows to the baseline source dataset. |
match_rate_percentage |
float
|
(Computed) The overall match rate expressed as a percentage (e.g., 99.98). |
is_perfect_match |
bool
|
(Computed) True only if there are exactly 0 mismatches. |
volume_shift |
int
|
(Computed) The net change in row volume (Target - Source). |
report_summary |
str
|
(Computed) A pre-formatted, human-readable markdown status report intended for CI/CD logs or PR comments. |
report_limit |
int
|
Internal configuration dictating the max columns to display
in the |
Source code in src/veridelta/models.py
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 | |
is_perfect_match
property
Evaluates if the datasets are completely identical under the configured rules.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if there are zero total mismatches. |
match_rate_percentage
property
Calculates the overall match rate expressed as a percentage.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The match percentage rounded to two decimal places (e.g., 99.98). |
mismatch_ratio
property
Calculates the ratio of mismatched rows to the baseline source dataset.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
A float representing the ratio (0.0 to 1.0+). |
report_summary
property
Generates a pre-formatted, human-readable status report.
This string aggregates all metrics and top column-level drifts into a clean markdown format ready for immediate pipeline logging.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The formatted execution summary. |
total_mismatches
property
Calculates the sum of all added, removed, and changed rows.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The total count of discrepancy events. |
volume_shift
property
Calculates the net change in row volume between the systems.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The net shift (Target rows - Source rows). |
SourceConfig
Bases: BaseModel
Configuration for a specific data source.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
str
|
File system path or URI to the data. |
format |
SourceType
|
The format of the file (e.g., 'csv', 'parquet'). |
options |
dict[str, Any]
|
Format-specific keyword arguments passed
directly to the underlying Polars reader (e.g., |
Source code in src/veridelta/models.py
The Engine
The core mathematical evaluation engine and I/O orchestration, powered by the Rust-based Polars backend.
Core engine for data ingestion and alignment.
This module houses the I/O loaders, the DataIngestor for dataset preparation,
and the DiffEngine which performs the high-performance Polars comparisons.
BaseLoader
Bases: ABC
Abstract base class for all data loaders.
Source code in src/veridelta/engine.py
load(config)
abstractmethod
Loads data from a source into a Polars LazyFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SourceConfig
|
The configuration detailing the path, format, and format-specific parsing options. |
required |
Returns:
| Type | Description |
|---|---|
LazyFrame
|
pl.LazyFrame: The lazy-loaded dataset graph. |
Source code in src/veridelta/engine.py
CSVLoader
Bases: BaseLoader
Loader for CSV files utilizing the fast Polars CSV scanner.
Source code in src/veridelta/engine.py
load(config)
Loads a CSV file into a Polars LazyFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SourceConfig
|
The source configuration. Extra options are
passed directly to |
required |
Returns:
| Type | Description |
|---|---|
LazyFrame
|
pl.LazyFrame: The lazy dataset graph. |
Source code in src/veridelta/engine.py
DataIngestor
Coordinates the loading, renaming, and structural alignment of datasets.
This class prepares raw external data for comparison by normalizing headers and dropping ignored columns before handing them off to the DiffEngine.
Source code in src/veridelta/engine.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
__init__(diff_config, source_config, target_config)
Initializes the ingestor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diff_config
|
DiffConfig
|
The master comparison configuration. |
required |
source_config
|
SourceConfig
|
File and format settings for the source. |
required |
target_config
|
SourceConfig
|
File and format settings for the target. |
required |
Source code in src/veridelta/engine.py
get_dataframes()
Loads and aligns both source and target datasets.
Returns:
| Type | Description |
|---|---|
tuple[LazyFrame, LazyFrame]
|
tuple[pl.LazyFrame, pl.LazyFrame]: The prepared (source_df, target_df). |
Source code in src/veridelta/engine.py
DiffEngine
The core mathematical engine that evaluates differences between datasets.
Source code in src/veridelta/engine.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 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 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 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 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | |
__init__(config, source_df, target_df)
Initializes the engine with datasets already aligned by the DataIngestor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DiffConfig
|
The master validation rules configuration. |
required |
source_df
|
LazyFrame
|
The aligned 'Left' (Legacy) dataset. |
required |
target_df
|
LazyFrame
|
The aligned 'Right' (Modern) dataset. |
required |
Source code in src/veridelta/engine.py
run()
Execute the end-to-end dataset comparison pipeline lazily.
Builds an optimized Polars computation graph (DAG) to guarantee deterministic alignment, preventing compute errors and memory exhaustion on large datasets. Data is only materialized into memory when absolutely necessary for execution.
Execution Pipeline
- Structural Alignment: Maps and prunes schemas to establish the Target as the authoritative structural contract.
- Validation & Integrity: Asserts primary key existence and uniqueness
(triggering a localized collection), and enforces the
SchemaMode. - Lazy Graph Construction: Builds the computation DAG for semantic normalization (regex sanitization) and type coercion.
- Relational Joins: Formulates the lazy anti-joins ('Added', 'Removed') and inner-joins ('Changed') to isolate discrepancies.
- Graph Execution: Executes the computation DAG via
.collect()to evaluate vectorized match expressions and compute exact row counts. - Artifact Persistence: Exports the materialized discrepancy dataframes to the configured storage backend, if requested.
Returns:
| Name | Type | Description |
|---|---|---|
DiffSummary |
DiffSummary
|
Execution report detailing match status, discrepancy counts, and column-level drift metrics. |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If schema constraints or primary keys are violated post-alignment. |
DataIntegrityError
|
If duplicate primary keys prevent deterministic joins. |
NotImplementedError
|
If the requested artifact export format is unsupported. |
Source code in src/veridelta/engine.py
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 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 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 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | |
LoaderFactory
Factory to return the appropriate loader based on the configured SourceType.
Source code in src/veridelta/engine.py
get_loader(source_type)
classmethod
Retrieves the correct loader instance for the given data format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_type
|
str
|
The format identifier (e.g., 'csv', 'parquet'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseLoader |
BaseLoader
|
An instantiated data loader. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the requested format is not yet supported. |
Source code in src/veridelta/engine.py
ParquetLoader
Bases: BaseLoader
Loader for Parquet files utilizing the Polars Parquet engine.
Source code in src/veridelta/engine.py
load(config)
Loads a Parquet file into a Polars LazyFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SourceConfig
|
The source configuration. Extra options are
passed directly to |
required |
Returns:
| Type | Description |
|---|---|
LazyFrame
|
pl.LazyFrame: The lazy dataset graph. |
Source code in src/veridelta/engine.py
Configuration Parser
Utilities for loading, parsing, and validating YAML files into strictly typed configuration objects.
Configuration parsing and validation from YAML files.
This module acts as the bridge between user-defined YAML configurations and the strict Pydantic models required by the execution engine.
load_config(path)
Loads and validates a Veridelta configuration from a YAML file.
The parser extracts the explicit source and target definition blocks,
then evaluates all remaining root-level YAML parameters as the master
DiffConfig.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The file system path to the YAML configuration. |
required |
Returns:
| Type | Description |
|---|---|
tuple[DiffConfig, SourceConfig, SourceConfig]
|
tuple[DiffConfig, SourceConfig, SourceConfig]: A tuple containing the validated master configuration, source configuration, and target configuration objects respectively. |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the file cannot be located, contains invalid YAML syntax, lacks the mandatory source/target blocks, or violates the strict Pydantic schema definitions. |
Source code in src/veridelta/config.py
Exceptions
The custom exception hierarchy. Consumers of the Python API should handle these specific errors to manage pipeline failures gracefully without silencing native Python runtime panics.
Custom exceptions for Veridelta operations.
This module defines the core exception hierarchy used throughout the
Veridelta framework. Consumers of the Python API can catch the base
VerideltaError to safely handle all framework-specific failures.
ConfigError
Bases: VerideltaError
Raised when configuration validation or schema enforcement fails.
This is triggered during pipeline initialization or schema validation
if mandatory parameters (like primary keys) are missing, or if strict
schema constraints (e.g., allow_removals, exact) are violated by
the provided datasets.
Source code in src/veridelta/exceptions.py
DataIntegrityError
Bases: VerideltaError
Raised when foundational data assumptions are violated.
This is typically raised during the pre-evaluation phase if primary keys are not unique within either dataset. Halting execution on this error prevents catastrophic join explosions and Out-Of-Memory (OOM) crashes during the Polars evaluation phase.
Source code in src/veridelta/exceptions.py
VerideltaError
Bases: Exception
Base exception for all Veridelta-specific errors.
Consumers should catch this exception to handle pipeline validation
failures gracefully without silencing standard Python runtime errors
(like MemoryError or ValueError).
Source code in src/veridelta/exceptions.py
Datasets
Built-in data utilities with network-resilient caching for testing, onboarding, and tutorials.
Built-in datasets for Veridelta testing and quickstart examples.
This module provides utilities to securely download, cache, and load sample datasets used in Veridelta's documentation and tutorials.
load_nyc_taxi()
Loads the NYC Taxi sample dataset.
Downloads the dataset from the official Veridelta repository and caches it locally. If the cached file is corrupted, it automatically evicts it and attempts a fresh download. Enforces a 15-second timeout.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: A Polars DataFrame containing the NYC Taxi sample data. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the download fails due to network or routing issues. |