API Reference
The building blocks of Veridelta. Explore the configuration schemas, column rules, and the core diffing engine.
Configuration Models
These models define how you configure a Veridelta comparison. You can pass these directly via Python, or define them in a YAML file.
Data models for Veridelta configuration and results.
ColumnRule
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. |
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. |
regex_replace |
dict[str, str] | None
|
Dictionary of {pattern: replacement} to sanitize text before comparison. |
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., {'M': 'Male'}). |
null_values |
list[str] | None
|
Specific string values to actively coerce to NULL (e.g., ['N/A', '-999']). |
treat_null_as_equal |
bool | None
|
If True, evaluates NULL == NULL as a successful match. |
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'). |
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. |
Source code in src/veridelta/models.py
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 | |
validate_pattern(v)
classmethod
Ensure 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, or None. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The validated regex string, or None if not provided. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the regex pattern cannot be compiled. |
Source code in src/veridelta/models.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
validate_regex_replace(v)
classmethod
Ensure all keys in the regex replacement dictionary are valid regex patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
dict[str, str] | None
|
A dictionary mapping regex patterns to their replacements, or None. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str] | None
|
The validated dictionary, or None if not provided. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any key in the dictionary is an invalid regex pattern. |
Source code in src/veridelta/models.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
DiffConfig
Bases: BaseModel
The master configuration for a Veridelta comparison run.
Attributes:
| Name | Type | Description |
|---|---|---|
source |
SourceConfig
|
Configuration for the 'Left' dataset. |
target |
SourceConfig
|
Configuration for the 'Right' dataset. |
primary_keys |
list[str]
|
Columns used to join and align the datasets. |
schema_mode |
SchemaMode
|
How strictly to enforce column existence and matching between sources. |
strict_types |
bool
|
If False, the engine will attempt to cast target columns to source types. |
default_absolute_tolerance |
float
|
Global absolute tolerance for all numeric columns. |
default_relative_tolerance |
float
|
Global relative tolerance for all numeric columns. |
default_treat_null_as_equal |
bool
|
Global setting for handling NULL == NULL. |
default_whitespace_mode |
WhitespaceMode
|
Global setting for stripping whitespace in strings. |
default_null_values |
list[str]
|
Global list of string values to aggressively coerce to NULL. |
rules |
list[ColumnRule]
|
List of per-column comparison overrides. |
threshold |
float
|
Allowed mismatch percentage (0.0 to 1.0) before failure. |
output_path |
str | None
|
Path to save the resulting diff report and artifacts. |
output_format |
SourceType
|
Format for exporting diff artifacts (e.g., parquet, csv). |
Source code in src/veridelta/models.py
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 | |
apply_schema_normalization()
Automatically lowercase user config keys if normalization is enabled.
Source code in src/veridelta/models.py
276 277 278 279 280 281 282 283 284 285 286 287 288 | |
DiffSummary
Bases: BaseModel
The high-level 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. |
is_match |
bool
|
Boolean indicating if the overall diff falls within the allowed threshold. |
Source code in src/veridelta/models.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
SchemaMode
Bases: str, Enum
Defines how strictly the engine enforces column schemas between datasets.
Source code in src/veridelta/models.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
ALLOW_ADDITIONS = 'allow_additions'
class-attribute
instance-attribute
Target can have new columns, but must contain every column present in the Source.
ALLOW_REMOVALS = 'allow_removals'
class-attribute
instance-attribute
Target is allowed to drop legacy columns, but cannot add any new columns.
EXACT = 'exact'
class-attribute
instance-attribute
Strict 1:1 mapping. Columns must be identical and in the exact same order.
INTERSECTION = 'intersection'
class-attribute
instance-attribute
Only diff columns that exist in both datasets, ignoring all others. (Default)
RELAXED_ORDER = 'relaxed_order'
class-attribute
instance-attribute
Strict 1:1 mapping, but order-agnostic. Columns must be identical, but sequence does not matter.
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 kwargs passed to the loader. |
Source code in src/veridelta/models.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
SourceType
Bases: str, Enum
Supported and roadmap data formats for ingestion.
Source code in src/veridelta/models.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
WhitespaceMode
Bases: str, Enum
Granular control over string whitespace stripping.
Source code in src/veridelta/models.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
BOTH = 'both'
class-attribute
instance-attribute
Strip both leading and trailing whitespace.
LEFT = 'left'
class-attribute
instance-attribute
Strip leading whitespace only.
NONE = 'none'
class-attribute
instance-attribute
Do not strip any whitespace.
RIGHT = 'right'
class-attribute
instance-attribute
Strip trailing whitespace only.
The Engine
The core mathematical diffing engine, powered by Polars.
Core engine for data ingestion and alignment.
BaseLoader
Bases: ABC
Abstract base class for all data loaders.
Source code in src/veridelta/engine.py
24 25 26 27 28 29 30 | |
load(config)
abstractmethod
Load data into a Polars DataFrame.
Source code in src/veridelta/engine.py
27 28 29 30 | |
CSVLoader
Bases: BaseLoader
Loader for CSV files using Polars.
Source code in src/veridelta/engine.py
33 34 35 36 37 38 | |
load(config)
Load a CSV file into a Polars DataFrame using the provided config options.
Source code in src/veridelta/engine.py
36 37 38 | |
DataIngestor
Coordinates loading and alignment of source and target datasets.
Source code in src/veridelta/engine.py
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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
__init__(config)
Initialize the ingestor with a master configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DiffConfig
|
The master DiffConfig object. |
required |
Source code in src/veridelta/engine.py
71 72 73 74 75 76 77 | |
get_dataframes()
Loads and aligns both datasets.
Source code in src/veridelta/engine.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
DiffEngine
The core mathematical engine that calculates differences.
Source code in src/veridelta/engine.py
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 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 | |
__init__(config, source_df, target_df)
Initialize the engine with datasets already aligned by the DataIngestor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DiffConfig
|
The master configuration. |
required |
source_df
|
DataFrame
|
The aligned 'Left' dataset. |
required |
target_df
|
DataFrame
|
The aligned 'Right' dataset. |
required |
Source code in src/veridelta/engine.py
132 133 134 135 136 137 138 139 140 141 142 143 144 | |
run()
Executes the comparison logic with safety checks and type alignment.
Source code in src/veridelta/engine.py
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 | |
LoaderFactory
Factory to return the appropriate loader based on SourceType.
Source code in src/veridelta/engine.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
get_loader(source_type)
classmethod
Returns the loader for the given type.
Source code in src/veridelta/engine.py
57 58 59 60 61 62 63 64 65 | |
ParquetLoader
Bases: BaseLoader
Loader for Parquet files using Polars.
Source code in src/veridelta/engine.py
41 42 43 44 45 46 | |
load(config)
Loader for Parquet files using Polars.
Source code in src/veridelta/engine.py
44 45 46 | |