feat: support float keys in native map_from_arrays and map_from_entries #7722
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7722"
general
weight: 0.35
viirya
Which issue does this PR close?
Closes #6549. Part of #6385.
Rationale for this change
#6992 sent floating-point map keys through JVM codegen dispatch for Spark compatibility. This PR restores Rust execution for
map_from_arraysandmap_from_entrieswith top-levelFLOATandDOUBLEkeys, including groupedcollect_listresults with adaptive query execution enabled.What changes are included in this PR?
LAST_WIN, the first occurrence determines the position and the last supplies the value. UnderEXCEPTION, the first invalid key determines the error. The executor JDK formats duplicate floating-point keys.map_from_arrayspreserves the original keys when they are distinct. When a duplicate forces a rebuild, normalization applies to every stored key in that row.map_from_entriesalways applies the normalization setting.spark.sql.mapKeyDedupPolicyand the effective normalization setting as constants when serializing the expression. This removes the need to inspect or compile Spark codegen stages, rewrite plans or transfer settings through JNI. Set both options before planning. Changing them on an existing plan or overriding them through task-local properties is unsupported. No new public configuration or JVM API is required.arrays_zipfrom evaluating a stateful child separately. Codegen dispatch preserves that child's evaluation and the bits Spark produces for NaN literals. The general stateful-input issue is tracked in #5781 and #5867. The fixed-width constructor restriction also limits peak memory before deduplication. Array columns, including variable-width and nested values, remain eligible. Struct and array keys containing floats retain codegen dispatch.How are these changes tested?
EXCEPTION, sliced inputs and the Arrow offset limit when a nested list is repeated or discarded.d89346d. Formatting andgit diff --checkpassed.map_from_arraysCriterion benchmark now covers eight distinctDOUBLEkeys and string values per row.Hosted comparison
Measurements and raw samples · Reproduction code
The fork-only harness used the native library built for
d89346dand a planner switch to select Rust or JVM dispatch. The switch is outside this PR. Each run checked the selected route and compared a fingerprint of the ordered entries, raw key bits and values with Spark. The clock covered the Parquet scan, map construction and output consumption. Planning and input generation were outside the timer.Median wall time in milliseconds on one AMD EPYC 9V74 runner, Spark 4.1.3, JDK 17,
local[2],LAST_WIN, three warmups and eight measured rounds per route with alternating order. For the first eight cases, 65,536 rows of array columns had either 32 distinct keys or 1–64 keys with duplicates in most rows. The batch size was 8,192.| Input | Builder | Keys | Rust (ms) | JVM dispatch (ms) | Spark (ms) |
|---|---|---|---:|---:|---:|
| Distinct |
map_from_arrays| FLOAT | 68.4 | 146.5 | 150.7 || Distinct |
map_from_entries| FLOAT | 53.4 | 120.9 | 144.4 || Distinct |
map_from_arrays| DOUBLE | 59.5 | 135.5 | 135.1 || Distinct |
map_from_entries| DOUBLE | 60.5 | 123.2 | 143.8 || Mixed |
map_from_arrays| FLOAT | 60.0 | 125.3 | 163.0 || Mixed |
map_from_entries| FLOAT | 59.6 | 103.9 | 158.9 || Mixed |
map_from_arrays| DOUBLE | 66.4 | 124.5 | 133.3 || Mixed |
map_from_entries| DOUBLE | 57.3 | 111.8 | 135.3 || Discard wide string |
map_from_arrays| FLOAT | 480.5 | 41.4 | 45.8 || Discard wide string |
map_from_entries| FLOAT | 490.6 | 22.2 | 25.9 |Why restrict computed inputs?
For array columns, JVM dispatch took 1.74–2.28 times as long as Rust in these runs. The last two rows bypass the input guard to measure the cost of constructing arrays in Rust. Both routes discard a 128 KiB string in favor of a short value on each of 2,048 rows. The outer null check cannot skip a non-null value that the map will later discard. Projecting just the same constructors in Rust produced 268,482,250 and 268,499,658 bytes of Arrow buffers across four 512-row batches. Only 21,418 bytes of string payload survived. The median sampled increase in process RSS during those queries was about 191 MiB for Rust and under 1 MiB for dispatch. RSS includes allocator reuse and JVM activity.
This is why the default routes these constructors through dispatch. Materialized string and nested array columns remain eligible. Neither these timings nor the wide-string example establish a crossover point for all input sizes. For non-floating keys,
LAST_WINalready uses dispatch.The separate
arrays_zipevaluation problem also affects non-floating keys. Its null check and body can evaluate the same stateful child on different sets of rows. The existing issue and agreed approach cover that behavior across expressions. #5867 handles nondeterministic children. Changing evaluation of all native zip operands would affect other callers and overlap that work.