Repository navigation
fix: infer get_data column types from all rows - #4
Merged
Merged
Conversation
pl.DataFrame infers dtypes from the first 100 rows. On long CBS tables that crashed when a series starts late (all null for 100 rows, as in 86103NED and 00372) and silently truncated floats that first appear after 100 integer rows (1.5 -> 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
get_databuilt its frame withpl.DataFrame(rows), and polars infers column types from the first 100 rows only. Long CBS tables hit this in two ways:The fix scans every row before choosing a type:
Evidence
Client().get_data("86103NED")andget_data("00372")raiseComputeError: could not append value: 100 of type: i64 to the builder.After: they return (197, 35) and (773, 39) frames in under half a second each.
TestGetData:test_column_null_for_first_hundred_rows: fails onmainwith theComputeErrorand passes here.test_float_after_hundred_ints_is_not_truncated: fails onmainwithassert 1 == 1.5and passes here.ruff check,ruff format --checkandty checkare clean.Merge Danger
Door: two-way
Blast Radius: dtypes
Columns that mix integers and floats beyond row 100 now come back as
Float64rather than truncatedInt64. That is a change in output for any caller who got integers before, but those integers were wrong. Type inference now reads every row, which costs little next to the HTTP fetch.🤖 Generated with Claude Code