fix(polars): NaN as missing, finite outlier fences, LazyFrame inputs - #224
Merged
Merged
Conversation
- #200: the Polars engine only counted nulls, so float NaN from a native Polars DataFrame/LazyFrame, an Arrow table or Polars-written Parquet was treated as a value: empty rows/columns were kept and missing_before was wrong. Native sources now read float NaN as null at ingestion (pl.from_pandas already did this for pandas input). Outlier fences are computed over finite values only, matching pandas drop_infinite, so +-inf no longer blows up the quantiles. - #203: a pl.LazyFrame source crashed whenever the run needed the pandas fallback ("cannot materialize source of type LazyFrame") and was rejected on the default path ("expected a pandas or polars DataFrame"). The fallback now collects it, and fd.clean(lazyframe) cleans it like a DataFrame and returns a LazyFrame. fallback_policy="error" still blocks before any collect. Closes #200 Closes #203
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
FreshData benchmark report —
|
| fixture | n_rows | n_cols | p50 s | p95 s | peak MB | repair % | false-repair % | preserve % | trust | monotonic | export % |
|---|
Authored-code reduction (Metric 6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#200: float NaN counted as a value. The Polars engine counted only nulls. So when a native Polars
DataFrame/LazyFrame, an Arrow table or Polars-written Parquet held float NaN, empty rows and columns were kept andmissing_beforewas wrong.pl.from_pandasalready did this for pandas input.drop_infinite, so ±inf no longer skews the quantiles and still gets flagged or clipped.#203:
pl.LazyFramesources.cannot materialize source of type LazyFrame), and the default path rejected them (expected a pandas or polars DataFrame).LazyFrame, andfd.clean(lazyframe)cleans it like aDataFrameand returns aLazyFrame.fallback_policy="error"still raises before anything is collected.Issue repros on this branch
Same output on Python 3.12 and 3.9:
Tests
tests/test_execution/test_polars_engine.py:DataFrame,LazyFrameand Arrow sources, and for Polars-written ParquetLazyFramethrough the default path,engine="auto", and Polars balanced/conservative;fallback_policy="error"still raisestests/test_polars_adapter.py: aLazyFrameround trip on the default path.Local lane
pytest -m "not online and not large"on Python 3.12 and 3.9 passes, except the five sandbox tests that also fail locally onmain. Targeted engine tests re-run after rebasing onto #220.ruff check .andmypy src/freshdatapass.Note: this and the DuckDB parity PR both touch
execution/backends/_polars.py, in separate hunks. Whichever merges second gets rebased.Closes #200
Closes #203