Skip to content

panic: array_repeat scalar path overflows total repeated-value count #22218

@Dandandan

Description

@Dandandan

Describe the bug

array_repeat can panic on scalar elements when the total repeated-value count overflows usize while summing counts.

To Reproduce

SELECT array_repeat(1, c)
FROM (
  VALUES
    (9223372036854775807),
    (9223372036854775807),
    (9223372036854775807)
) AS t(c);

Actual behavior

thread 'main' panicked at .../library/core/src/iter/traits/accum.rs:204:1:
attempt to add with overflow

Expected behavior

Return an execution error for an output-size overflow, not a panic.

Notes

The overflow comes from summing the per-row repeat counts before building the result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions