fix(duckdb): exact metadata scan, all-empty columns, ordered dedup, Unicode whitespace - #223
Merged
Merged
Conversation
…nicode whitespace - #199: MetadataScanner.from_duckdb ran SUMMARIZE (twice), whose stddev_samp raises "STDDEV_SAMP is out of range" on any inf/NaN float column, and it rebuilt missing_before from a rounded null percentage. It now reads types from DESCRIBE and runs one exact COUNT/approx_count_distinct query, counting float NaN as missing like pandas. The pipeline reads real NaN (from Arrow, Parquet or Polars sources) as NULL, computes outlier fences over finite values only (pandas drop_infinite), and writes non-finite fill values as a cast literal instead of a bare `inf` identifier. - #201: when every column was empty the engine recorded the drop but ran `SELECT *` and returned every column. It now returns a zero-column frame that keeps the row count, as the pandas pipeline does (same fix for the Polars engine, whose zero-column frame had height 0). Output formats that cannot hold rows without columns (polars/arrow), and native DuckDB relations (which keep the columns), record the difference on the report. - #202: full-row dedup used SELECT DISTINCT, so the row order was arbitrary and duplicate_keep was ignored. A scan-order ordinal now keeps the first/last occurrence and restores the input order (the ordering sort only runs when rows are actually removed). - #204: whitespace stripping used RE2 `\s` (ASCII only, no \v) on DuckDB and Rust's whitespace set (no \x1c-\x1f) on Polars. Both now strip exactly the str.isspace set (_util.PY_WHITESPACE), matching the pandas engine. Closes #199 Closes #201 Closes #202 Closes #204
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
#199: inf/NaN crash and inexact
missing_before.MetadataScanner.from_duckdbno longer runsSUMMARIZEtwice. That call raisedSTDDEV_SAMP is out of rangeon any inf/NaN float column, and it rebuiltmissing_beforefrom a rounded null percentage.DESCRIBEand runs one exactCOUNT/approx_count_distinctquery, counting float NaN as missing the way pandas does.drop_infinite.infwould be parsed as a column name.#201: dropping all-empty columns.
SELECT *, so every column came back.backend_differencesentry:output_format="duckdb"relations, which cannot have zero columns and so keep them#202: full-row dedup order.
SELECT DISTINCTreturned rows in arbitrary order and ignoredduplicate_keep.row_number()ordinal now keeps the first or last occurrence and restores input order:QUALIFY … ORDER BYordinal.#204: Unicode whitespace.
\s, which is ASCII-only and misses\v. Polars stripped with Rust's whitespace set, which misses\x1c–\x1f.str.isspaceset (_util.PY_WHITESPACE, checked against Python by a test), so they match the pandas engine.Tests
tests/test_execution/test_engine_parity_edge_cases.py, run on pandas, Polars and DuckDB:PY_WHITESPACEcharacter, compared againststr.strip()missing_beforeis exact on 100,003 rowskeep="first"/"last"matches pandas order on 5 and 20k rows, including a Parquet source, withduckdb_threads=4tests/test_execution/test_metadata_scanner.pyadds exact counts with inf/NaN.Verification
pytest -m "not online and not large"on Python 3.12 (numpy 2.5) and 3.9 (pandas 1.5.3): all pass except the five sandbox tests that also fail locally onmain(they need an installed package). Targeted engine tests re-run after rebasing onto fix(text): normalize ArrowDtype string and categorical columns #220.duckdb==0.10.0runs the parity, metadata and DuckDB engine tests: 42 passed.ruff check .andmypy src/freshdatapass.Closes #199
Closes #201
Closes #202
Closes #204