Repository navigation
Fix .| transforms for columns that start with many NULLs - #2483
Conversation
|
Hi! Thanks! What are the performance implications? |
The extra cost is in building the DataFrame, it grows with the row count, and the memory part is larger than the PR description suggests (it only gave time). DataFrame construction only, with rows already fetched (no query or display time). Polars 2.1.0, Python 3.13, Apple M3 Max, median of repeated runs; columns cycle through int, float, str, datetime and nullable Decimal:
Peak memory for 1,000,000 × 5: the process holds about 424 MB with the fetched rows; building the DataFrame raises the peak to about 525 MB on main and about 770 MB with this PR. If that matters, I can change it to try the default inference first and retry with Would you like that version, or keep the simpler full scan? |
rolandwalker
left a comment
There was a problem hiding this comment.
Let's keep it simple!
This PR fixes issue #2482.
Description
A
.|transform or.>save failed withComputeErrorwhen a column wasNULLin the first 100 rows and had a value later, because Polars infers column types from the first 100 rows by default.run_polars_transform()now passesinfer_schema_length=None, so all rows are used.Cost: building the DataFrame scans more rows. For 200,000 rows and 5 columns it went from 0.11 s to 0.13 s on my machine.
Not covered: a column that mixes zero dates (which arrive as strings such as
'0000-00-00') with real dates still fails, as it does on main.The new test uses real Polars with an integer and a string after 100
NULLrows. It fails on main (2 failed) and passes with the change.mycli_test/pytests: 3624 passed, 87 skipped, 7 xfailed. The behave tests, which need a MySQL server, were not run locally.Checklist
changelog.mdfile.mycli/AUTHORS.txtfile (or it's already there).