Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Polars (Rust)

polars-004 medium

Commit: 052e68fc47

Task prompt

Fix the sortedness tracking for concat\_str with multiple inputs. The optimizer incorrectly marks the output of concat\_str on multiple columns as sorted, which can cause wrong results in downstream operations that rely on sorted invariants. The fix should not propagate sortedness metadata when concat_str operates on multiple input columns, since concatenating multiple sorted columns does not produce a sorted result.

Implement the fix. Run the test suite with the test command to verify.

ApproachTests PassPrecisionRecallF1DurationCost
no-bobbin100.0%100.0%66.7%80.0%4.4m$0.81

polars-004_f1_boxplot.svg

polars-004_duration.svg

Ground truth files: crates/polars-plan/src/plans/optimizer/sortedness.rs, py-polars/tests/unit/lazyframe/test_optimizations.py, py-polars/tests/unit/streaming/test_streaming_join.py

Files touched (no-bobbin): crates/polars-plan/src/plans/optimizer/sortedness.rs, py-polars/tests/unit/lazyframe/test_optimizations.py


polars-005 medium

Commit: 8f60a2d641

Task prompt

Fix inconsistent behavior when dividing literals by zero. Currently, pl.lit(1) // pl.lit(0) produces different results depending on the dtype: panics for unsigned types, returns 0 for same-type signed ints, and returns null for mixed types. The correct behavior is to always return null when dividing by zero, matching standard SQL/dataframe semantics. Fix the literal simplification logic in the optimizer to handle division-by-zero cases consistently.

Implement the fix. Run the test suite with the test command to verify.

ApproachTests PassPrecisionRecallF1DurationCost
no-bobbin100.0%100.0%66.7%79.4%6.4m$1.74

polars-005_f1_boxplot.svg

polars-005_duration.svg

Ground truth files: crates/polars-plan/src/dsl/expr/mod.rs, crates/polars-plan/src/plans/optimizer/simplify_expr/mod.rs, crates/polars-utils/src/floor_divmod.rs, py-polars/tests/unit/expr/test_literal.py

Files touched (no-bobbin): crates/polars-plan/src/plans/optimizer/simplify_expr/mod.rs, crates/polars-utils/src/floor_divmod.rs, py-polars/tests/unit/expr/test_literal.py