IqrOutlierCheck: without rows in the days before, the run crashes with a TypeError

Open Beginner friendly
#199 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, sql

Research direction

Start with IqrOutlierCheck._check and DataQualityCheck.check in src/koality/checks.py, using the issue's reproduction YAML to confirm the crash when earlier rows are absent. Handle the NULL quartiles so the check returns a FAIL or ERROR with a message that there is no history for computing quartiles; done means koality run reports that result instead of a traceback.

Written by the indexing model from the issue text.

Description

When the checked day has rows but none of the `interval_days` days before it does (e.g. a new table), `IqrOutlierCheck`'s quartiles are NULL, so `_check` sets `lower_threshold`/`upper_threshold` to `None`. `DataQualityCheck.check` then compares `None <= value`, which raises:

```
TypeError: '<=' not supported between instances of 'NoneType' and 'float'
```

The exception isn't caught, so `koality run` prints a traceback and exits with 2 instead of giving the check a `FAIL` (or `ERROR`) result.

Reproduce:

```yaml
name: t
database_setup: "CREATE TABLE t AS SELECT DATE '2024-01-31' AS d, 5 AS v"
database_accessor: ""
defaults:
filters:
p: {column: d, value: "2024-01-31", type: date}
check_bundles:

  • name: b
    checks:
    • {check_type: IqrOutlierCheck, table: t, check_column: v, interval_days: 7, how: both, iqr_factor: 1.5}
      ```

Where: `src/koality/checks.py`, `IqrOutlierCheck._check` (takes the NULL thresholds over) and `DataQualityCheck.check` (compares them).

Expected: the check fails (like any check whose value can't be compared), with a message saying there's no history to compute the quartiles from.

Dominant language
Python
Stars
4
Forks
3
Avg merge
28m
Merged PRs (30d)
47

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ottogroup/koality

All issues in ottogroup/koality

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.