What is the problem the feature request solves?
spark_map_sort currently slices keys and invokes Arrow sorting for every nonempty map, including maps with exactly one entry. A singleton already has its only possible ordering, so this per-row allocation and kernel dispatch adds avoidable normalization cost before nested-key hashing.
Describe the potential solution
For supported flat key types, append a singleton's original entry index directly to the global permutation. Keep Arrow sorting for other rows and for key types whose sorting can report errors. Use a batch-level check and a specialized fallback loop to avoid adding a singleton branch to each row of batches without eligible singletons.
Preserve output values, offsets, null buffers, schema metadata, early returns, and unsupported-key errors, including sliced maps and physical entries under null maps. Hashing behavior and configuration defaults should remain unchanged.
Additional context
Follow-up to the benchmark isolation work in #5822 (which closed #5818). Validate normalization-only, hash-only, and combined execution separately, including singleton, empty, mixed and larger maps, nulls, long strings, and sliced inputs. Independently remeasure flagged regressions.
What is the problem the feature request solves?
spark_map_sortcurrently slices keys and invokes Arrow sorting for every nonempty map, including maps with exactly one entry. A singleton already has its only possible ordering, so this per-row allocation and kernel dispatch adds avoidable normalization cost before nested-key hashing.Describe the potential solution
For supported flat key types, append a singleton's original entry index directly to the global permutation. Keep Arrow sorting for other rows and for key types whose sorting can report errors. Use a batch-level check and a specialized fallback loop to avoid adding a singleton branch to each row of batches without eligible singletons.
Preserve output values, offsets, null buffers, schema metadata, early returns, and unsupported-key errors, including sliced maps and physical entries under null maps. Hashing behavior and configuration defaults should remain unchanged.
Additional context
Follow-up to the benchmark isolation work in #5822 (which closed #5818). Validate normalization-only, hash-only, and combined execution separately, including singleton, empty, mixed and larger maps, nulls, long strings, and sliced inputs. Independently remeasure flagged regressions.