Skip to content

fix(array): preserve constants when zip selects one branch - #11373

Merged
danking merged 1 commit into
developfrom
dk/preserve-zip-constants
Nov 9, 2026
Merged

danking merged 1 commit into
developfrom
dk/preserve-zip-constants

Conversation

@danking

@danking danking commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

When zip's mask is uniformly true or false (including null masks, which select the false branch), executing the selected ConstantArray materializes it unnecessarily. Scalar access then logs Scalar function vortex.zip() returned non-constant array from execution over all scalar inputs.

Return the selected branch cast to the output dtype without executing it again. Removing the zip node already makes execution progress; the caller can preserve constants with Columnar or continue materializing with Canonical.

Added a parameterized regression test for true, false, and null masks, with matching branch types and with nullable/non-nullable branches. It checks constant encoding, values, and output nullability.

Validation: reviewed the patch and execution paths. Tests, formatting, and lints were not run locally, following AGENTS.md's instruction to leave verification execution to the user.

Implemented and opened by Codex at Daniel King's request. Daniel King (@danking) is the responsible human.

Signed-off-by: Daniel King <dan@spiraldb.com>
@danking danking self-assigned this Nov 9, 2026
@danking danking added the changelog/fix A bug fix label Nov 9, 2026
@danking
danking enabled auto-merge (squash) November 9, 2026 22:04
@codspeed

codspeed Bot commented Nov 9, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 19.55%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚡ 4 improved benchmarks
✅ 1912 untouched benchmarks
⏩ 48 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation chunked_bool_canonical_into[(1000, 10)] 37.9 µs 29.6 µs +28.15%
⚡ CPU Simulation bench_compare_varbin[(50000, 2)] 164.3 µs 134.8 µs +21.92%
⚡ CPU Simulation bench_compare_sliced_dict_varbinview[(1000, 10000)] 92.9 µs 80.8 µs +14.96%
⚡ CPU Simulation bench_compare_sliced_dict_varbinview[(9999, 10000)] 235.4 µs 207 µs +13.74%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing dk/preserve-zip-constants (32bc943) with develop (2e1b05b)

Open in CodSpeed

Footnotes

  1. 48 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@danking
danking merged commit 7b36f7f into develop Nov 9, 2026
98 of 99 checks passed
@danking
danking deleted the dk/preserve-zip-constants branch November 9, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants