fix(rust): Report List dtype in schema for Expr.quantile with multiple quantiles #29084
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 403 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.359
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #29084"
general
weight: 0.35
BitWeaverDev
Summary
Expr.quantile()accepts either a single quantile (returns a scalar) or a list of quantiles (returnslist[f64], one value per requested quantile), exactly as documented in its own docstring. The physical evaluator honors this correctly, butcollect_schema()always predicted the scalar dtype for the list case, producing a schema that does not match the actual materialized result:Closes #29030.
Root cause
Expr.quantile(quantile, method)builds a binary function node (dsl/mod.rs): field 0 is the target column, field 1 is the quantile-probabilities expression (List(Float64)when a Python list is passed, scalarFloat64otherwise).Schema inference for
Quantilecalledmoment_dtype(), which goes throughmap_dtype()and reads onlyfields[0]. It never inspectsfields[1], the one thing that actually determines whether the output is scalar or list, so it always predicted the scalar shape.The physical dispatch (
dispatch/misc.rs::quantile) gets this right — it branches onfields[1]'s dtype:confirming the schema function is the side that's wrong.
Fix
Added
FieldsMapper::quantile_dtype(), following the same two-field-read convention already used by the neighboringpow_dtype/log_dtypehelpers in the same file: compute the moment dtype as before via the existingmoment_dtype(), then wrap it inListwhenfields[1]'s dtype isList, mirroring exactly the branch the physical dispatch takes on that same field. UsesField::coerce, the same method already used bynested_sum_type/nested_mean_median_typein this file, so no new patterns are introduced.Only checking
DataType::List(notArray) is deliberate — it matches exactly what the physical dispatch checks, so schema and runtime stay in lockstep.rolling_quantile/rolling_quantile_by(a different, always-scalar calling convention) are untouched and out of scope.Test plan
test_quantile_list_schema_29030inpy-polars/tests/unit/operations/test_statistics.py, covering both the list case (schema now matches, and isList(Float64)) and the scalar case (must not regress to always wrapping inList).test_statistics.py,test_aggregations.py, rolling quantile tests intest_rolling.pyx2) — 78 passed, confirming the rolling-quantile arms are unaffected.make test— 18949 passed, 233 skipped, 7 xfailed.make lint(ruff, pyrefly, mypy, typos) — clean.cargo clippy -p polars-plan --all-targets --all-features— zero warnings from the changed code.cargo fmt -p polars-plan --check— clean.