Executor¶
Module containing the actual check execution logic.
CheckExecutor ¶
CheckExecutor(config: Config, duckdb_client: DuckDBPyConnection | None = None, verbose: bool | None = None, **kwargs: object)
Provide all the logic to actually run checks.
Contains methods to execute checks, to create the failed checks log, and to export DQM results to a database table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
Koality configuration object |
required |
duckdb_client
|
DuckDBPyConnection | None
|
DuckDB client for interacting with DuckDB (optional).
If not provided, an in-memory connection will be created, with the config's |
None
|
Source code in src/koality/executor.py
backend
property
writable
¶
backend: Backend
The backend that reads source tables and writes results for the attached database.
It follows duckdb_client, database_provider and config.database_accessor, so it is rebuilt if any
of them changes, unless a backend was assigned explicitly.
__call__ ¶
Execute all checks and return results.
Source code in src/koality/executor.py
aggregate_values
staticmethod
¶
Join a list of values into a comma-separated, sorted, deduplicated string.
execute_checks ¶
Instantiate and execute all checks.
When walking through the different checks, parameters are updated using global defaults, check defaults of bundles, and a check's parameters. Check results are stored in a results dict for further processing.
Source code in src/koality/executor.py
fetch_data_into_memory ¶
Fetch all required data into DuckDB memory before executing checks.
This method aggregates all data requirements (tables, columns, filters) from the checks, constructs efficient bulk-SELECT queries, and executes them to populate in-memory DuckDB tables. This avoids executing a separate query for each check.
Data is written to this executor's own in-memory staging catalog, never to the session's default catalog, so source tables are not modified.
Source code in src/koality/executor.py
find_missing_columns ¶
Return a problem for each source table or column the checks read that the database doesn't have.
Every check's check, filter, join and date columns are looked up in its tables through the backend
(Backend.columns), and each problem names the bundle, the check (its index in the bundle) and the
table or column, so all of them can be reported at once. Names are compared case-insensitively; for a
struct field such as info.shop, only the column (info) is looked up.
Source code in src/koality/executor.py
get_data_requirements ¶
Aggregate the data requirements of all checks (see data_requirements).
get_failed_checks_msg ¶
Get an aggregated message for all failed checks.
Uses the message attribute of all checks and aggregates it.
Returns:
| Type | Description |
|---|---|
str
|
Aggregated, sorted, newline separated messages of failed checks. |
Source code in src/koality/executor.py
load_to_database ¶
Append koality's DQM results to result_table.
The backend of the attached database writes them (see koality.backends): for DuckDB-attached
databases, result_table is created if needed and resolved like a check's table; for BigQuery,
it is written through BigQuery itself.
Source code in src/koality/executor.py
create_checks ¶
create_checks(config: Config, database_provider: DatabaseProvider | None = None) -> list[DataQualityCheck]
Create the checks of all bundles of config, with their merged defaults; no database is needed.
Raises:
| Type | Description |
|---|---|
KoalityError
|
If a check's settings don't work together (e.g. a distinct count of |
Source code in src/koality/executor.py
data_requirements ¶
data_requirements(checks: Iterable[DataQualityCheck]) -> defaultdict[str, defaultdict[str, set]]
Aggregate the tables, columns and filter groups that checks read, which a run fetches into memory.
Returns:
| Type | Description |
|---|---|
defaultdict[str, defaultdict[str, set]]
|
A mapping of each table to its required "columns" and its unique "filters" groups (see |
Source code in src/koality/executor.py
fetch_query ¶
fetch_query(table: str, requirements: Mapping[str, set], backend: Backend) -> str
Return the SELECT that fetches table's required columns and rows from the source, in backend's SQL.
requirements is the table's entry of data_requirements: its filter groups are combined into one WHERE
clause, which ORs the date conditions and ANDs them with the other filters.
Source code in src/koality/executor.py
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 | |