Skip to content

cardinality returns incorrect results for ragged nested arrays #23270

Description

@lyne7-sc

Describe the bug

cardinality() returns incorrect results for ragged nested arrays.

For nested arrays, cardinality() should count the total number of leaf elements. However, the current implementation computes array dimensions using the first child array and then multiplies those dimensions. This works for rectangular nested arrays, but gives incorrect results for ragged nested arrays.

To Reproduce

SELECT cardinality([[1], [2, 3]]);

Current result:
2

Expected result:
3

Expected behavior

No response

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