Repository navigation
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
JohnnyWilson16
left a comment
There was a problem hiding this comment.
Sorry for the slow review, @alibro005. This sat for 10 days. Thanks for the fix and the regression test.
I merged it with current main (clean, no conflicts) and ran the suite: 116 passed. The planner part works: suggest_plan no longer plans parse_currency for ["$10.00", "$20.00", "$30.00", "REF-9921"].
1. Replay path still loses data (blocking). apply_plan still strips and coerces with no check (src/freshdata/_core/backends.py:114-116 for pandas, :295-297 for Polars). A plan built on a clean batch and applied to a later batch still breaks it, on both engines:
plan = fd.suggest_plan(pd.DataFrame({"amt": ["$10.00", "$20.00", "$30.00", "$40.00"]}))
fd.apply_plan(pd.DataFrame({"amt": ["$50.00", "REF-9921", "N/A"]}), plan)
# amt -> [50.0, -9921.0, nan]suggest_plan → apply_plan is the main 3.x path, so #533 is only half fixed. Can you apply the same check in apply_plan (skip the action for that column)? If you'd rather keep this PR small, change Fixes #533 to Part of #533 and I'll open a follow-up.
2. CHANGELOG. Mixed columns now stay strings instead of being parsed. That is a user-visible change, so please add a line under [Unreleased] (CONTRIBUTING.md:54).
3. Nit. The nested-ternary map is hard to read, and it makes stage_dtypes about 3x slower on a 1M-row currency column (0.51 s → 1.65 s). A vectorized check does the same job:
text = out[col].astype(str).str.strip()
invalid = out[col].notna() & text.ne("") & ~text.str.fullmatch(CURRENCY_REGEX)Happy to merge once 1 and 2 are addressed.
What changed?
Why?
Previously, the currency parser removed non-numeric characters before checking whether a value was actually a currency. This could cause values like
REF-9921to be converted into-9921.This change makes sure that columns containing non-currency values are left unchanged instead of being incorrectly converted.
Fixes #533
How was it tested?
tests/test_stages.py.pytest.pytest -m "not online and not large".Any performance impact?
Any compatibility concerns?
Documentation updated?