Fixes 33544: derive datalake validation fixtures from EXECUTION_DATE - #33546
Conversation
The fixture rows were built at module import time from datetime.utcnow(), while the test case handed to the validator declares execution_date=EXECUTION_DATE.timestamp() - a fixed 2021-07-03. The data and the declared execution date were therefore about five years apart, by a margin that changed on every run. Derive the eight row timestamps from EXECUTION_DATE instead, and run the parametrized test under @freeze_time(EXECUTION_DATE) so anything reading the clock during validation sees the instant the data was built around. Scope, stated plainly: no test in the file asserts on inserted_date today - it appears only in the DataFrame column list - so nothing is failing now. This removes the wall-clock dependency before an assertion or a validator change inherits it. All 57 cases pass and the file no longer calls datetime.utcnow(). freezegun is already in ingestion/setup.py's test extras. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ Approved🟢 Low risk Derives datalake validation fixture timestamps from OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
| from datetime import datetime, timedelta | ||
|
|
||
| import pytest | ||
| from freezegun import freeze_time |
There was a problem hiding this comment.
This top-level import makes the module uncollectable in supported local unit-test environments. Both nox -s unit and make install_dev_env install the test-unit extra, but freezegun is declared only in the separate test extra. As a result, these documented workflows fail with ModuleNotFoundError before running any tests. Add freezegun to the unit-test dependency set or avoid requiring it here.
There was a problem hiding this comment.
this should fine as nox -s unit-tests does install all the deps, and tests are green on this pr.
There was a problem hiding this comment.
You're right that nox -s unit-tests installs the test extra, so that workflow is covered and the green run is expected. My concern is the other supported unit-test path: nox -s unit and make install_dev_env install test-unit, where freezegun is not included. Since this test lives under tests/unit, those workflows can still fail during collection with ModuleNotFoundError. Please either add freezegun to test-unit or avoid the import; otherwise, if unit-tests is the only intended workflow, the dependency finding can be dismissed.
There was a problem hiding this comment.
nox -s unit is not strictly recommended for all unit tests. Unit tests do include many other packages that aren't being installed with test-unit extras. test-unit seems bare minimum and I couldn't find use of it in any workflows or recommendations.
There was a problem hiding this comment.
That's fair. I overstated this as a supported-environment blocker. nox -s unit is a minimal/legacy session whose test-unit extra already omits dependencies needed by various unit tests, while the full nox -s unit-tests workflow installs .[test], which includes freezegun. make install_dev_env is likewise a development setup and does not guarantee that every unit test is runnable. This import therefore does not introduce a uniquely actionable dependency regression, so I’m withdrawing the finding; no change is needed.
✅ Playwright Results — workflow succeededValidated commit ✅ 110 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 25m 1s ⏱️ Max setup 5m 17s · max shard execution 12m 42s · max shard-job elapsed before upload 18m 50s · reporting 3s 🌐 235.47 requests/attempt · 1.79 app boots/UI scenario · 0.00% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
|



Describe your changes:
Fixes #33544. Salvaged from the closed PR #33248 (tracking: #33528).
The fixture rows in
test_validations_datalake.pywere built at module import time from the wallclock, while the test case handed to the validator declares a fixed execution date:
So the data and the declared execution date sat about five years apart, by a margin that changed on
every run. This derives the eight timestamps from
EXECUTION_DATEand runs the parametrized testunder
@freeze_time(EXECUTION_DATE), so anything that reads the clock during validation sees theinstant the data was built around.
Scope, stated plainly: no test in the file asserts on
inserted_datetoday — it appears only inthe
DataFramecolumn list — so nothing is failing now and I could not reproduce a red run. This isdeterminism hardening: it removes the wall-clock dependency before an assertion or a validator change
inherits it, most visibly around a UTC day boundary where
utcnow()at import and the assertion canland on different days.
freezegunis already declared iningestion/setup.py's test extras (line 526).Type of change:
High-level design:
N/A — test fixture change, 10 lines.
Tests:
Use cases covered
fixed, known relationship to the declared execution date.
Unit tests
No new tests; the existing 57 parametrized cases now run deterministically.
Backend integration tests
Not applicable — ingestion only.
Ingestion integration tests
Not applicable — this is a unit-test fixture.
Playwright (UI) tests
Not applicable.
Manual testing performed
python -m pytest tests/unit/observability/data_quality/test_validations_datalake.py— 57 passed.main— also 57 passed, which is why this is describedas hardening rather than a fix.
datetime.utcnow()no longer appears in the file, and thatinserted_dateis referencedonly by the
DataFramecolumn list.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #33544.🤖 Generated with Claude Code
The PR is not safe to merge until
freezegunis available in the supported unit-test environments or the new dependency is avoided.Findings
Summary
This PR anchors datalake validation fixture timestamps to the fixed execution date and freezes the validator clock for deterministic inserted-row-count testing.
EXECUTION_DATE.Reviews (1) · Last reviewed commit: "Fixes 33544: derive datalake validation ..."