Skip to content

fix array_repeat scalar path overflows total repeated-value count#22274

Open
xiedeyantu wants to merge 1 commit into
apache:mainfrom
xiedeyantu:array_repeat
Open

fix array_repeat scalar path overflows total repeated-value count#22274
xiedeyantu wants to merge 1 commit into
apache:mainfrom
xiedeyantu:array_repeat

Conversation

@xiedeyantu
Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

The scalar path of array_repeat can overflow while computing the total number of repeated values. Previously, the implementation used unchecked accumulation for these totals, which could lead to overflow behavior that was not explicitly handled. This change makes the capacity and offset calculations overflow-safe and returns a clear execution error when the total output size exceeds usize.

What changes are included in this PR?

  • Adds overflow checks for the total repeated value count in the scalar array_repeat path.
  • Adds overflow checks for outer and inner total size calculations in the list repeat path.
  • Preserves the existing behavior where non-positive counts are treated as zero.
  • Adds sqllogictest coverage for the overflow error case.

Are these changes tested?

  • Yes. A new sqllogictest covers the scalar overflow failure case for array_repeat.
  • Existing related tests continue to pass.

Are there any user-facing changes?

  • Yes. For extremely large inputs, array_repeat now returns a clear execution error instead of relying on implicit overflow behavior.
  • Normal inputs are unchanged.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels May 16, 2026
@xiedeyantu xiedeyantu changed the title array_repeat scalar path overflows total repeated-value count fix array_repeat scalar path overflows total repeated-value count May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: array_repeat scalar path overflows total repeated-value count

1 participant