Skip to content

array_repeat function does not handle null values in count array #20075

@lyne7-sc

Description

@lyne7-sc

Describe the bug

Follow-up work from PR #20049.

The current implementation of array_repeat does not correctly handle null inputs, which leads to behavior that is
inconsistent with typical SQL null semantics.(potential bug)

To Reproduce

Example input:

array = [1, 2, 3]
count = [2, NULL, 1]

Run:

SELECT array_repeat(array, count);

Current behavior:

[
  [1, 1],
  [], 
  [3]
]

Expected behavior

The function should be null-propagating with respect to count:
If count[i] is NULL, result[i] should be NULL

[
  [1, 1],
  NULL,
  [3]
]

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions