Repository navigation
fix(freshcore): fall back for non-scalar dtypes and wide ints, restore integer dtypes, keep non-string labels - #389
Merged
Conversation
…e integer dtypes, map non-string labels The FreshCore native arrays only carry float, bool and string values, and the adapter rebuilt results from plain lists keyed by str(label). That silently changed dtypes and column labels: - Datetime (naive and tz-aware), timedelta, categorical, period and interval columns were sent as str(v) and came back as object columns of strings. _unsupported_reason() now falls back for them, naming the columns and dtype kinds, so the run goes through the pandas reference path (and fallback_policy="error" raises FallbackError). - Integer columns holding a value beyond +/-2**53 were rounded by the float64 round-trip. They now fall back too. - int64, nullable Int64 and other integer widths came back as float64. _frame_from_native() now casts each integer input column back to its input dtype when every returned value is integral and in range (missing values only for nullable dtypes). Otherwise the column stays float64 and the change is recorded in report.backend_differences (step "dtypes"). - Distinct labels whose str() collides, before or after column-name normalization (1 and "1", or 1 and " 1 "), collapsed into one native column with no record. They now fall back. Non-colliding non-string labels (for example 0 and 1 from a headerless CSV) are mapped back to the original labels instead of coming back stringified. Docs: new rows in docs/fallback-matrix.md and matching notes in docs/backends.md and docs/freshcore.md. Tests: tests/test_execution/test_freshcore_dtype_fidelity.py covers each fallback (identical pandas output, recorded reason, FallbackError under fallback_policy="error"), integer dtype restoration, recorded dtype differences, and non-string label round-trips with a fake native module. Closes #262 Refs #232 (part 2)
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 was referenced Sep 15, 2026
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
FreshCore's native arrays only carry float, bool and string columns, and the adapter rebuilt results from plain lists keyed by
str(label). That silently changed dtypes and labels. This PR:int64, nullableInt64, other widths) when every returned value is integral and in range. Missing values are allowed only for nullable dtypes. Otherwise the column staysfloat64and the change is recorded inreport.backend_differences(step"dtypes").1and"1",1and" 1 "). Previously one column silently overwrote the other.0,1from a headerless CSV) back to the original labels.All new fallbacks use the existing fallback path, so
fallback_policy="error"raisesFallbackError.docs/fallback-matrix.md,docs/backends.mdanddocs/freshcore.mdlist the new triggers.Not changed here: bool columns still come back as nullable
boolean, and float32 / nullableFloat64still come back asfloat64.Tests
New
tests/test_execution/test_freshcore_dtype_fidelity.pyuses a fake native module:Int64/int64/uint64, colliding labels before and after renaming) gives pandas-equal output, dtypes and actions, with the recorded reason. Each also raisesFallbackErrorunderfallback_policy="error".big[0] == 2**53 + 1.int64,Int64,Int8anduint16round-trip through the native path with their dtype and match the pandas engine.float64and are recorded inbackend_differences.Int64, distinct mixed labels) stay native.Verification
ruff check .: passesmypy src/freshdata: no issues (202 files)Closes #262
Refs #232 (part 2)