Repository navigation
Support CARDINALITY() in indexes - #4100
Merged
Merged
Conversation
pengpeng-lu
reviewed
Apr 21, 2026
pengpeng-lu
reviewed
Apr 21, 2026
pengpeng-lu
reviewed
Apr 21, 2026
normen662
self-requested a review
April 22, 2026 07:34
robert-brunel
force-pushed
the
cardinality-index
branch
from
April 23, 2026 14:03
3d9ec65 to
dc19c5c
Compare
normen662
requested changes
May 1, 2026
robert-brunel
force-pushed
the
cardinality-index
branch
from
May 1, 2026 16:16
dc19c5c to
0ce51df
Compare
robert-brunel
force-pushed
the
cardinality-index
branch
2 times, most recently
from
May 13, 2026 14:45
233e334 to
7a80efd
Compare
pengpeng-lu
reviewed
May 13, 2026
pengpeng-lu
reviewed
May 13, 2026
robert-brunel
force-pushed
the
cardinality-index
branch
from
May 14, 2026 10:15
7a80efd to
c5f6aa7
Compare
alecgrieser
requested changes
May 14, 2026
alecgrieser
left a comment
Collaborator
There was a problem hiding this comment.
I have a few small thoughts. The big ones here are more observations for future work rather than change requests, per se. I did have a few remaining questions that may be best answered with additional comments
alecgrieser
approved these changes
May 14, 2026
alecgrieser
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. I think the issue in the comment isn't quite right, but that doesn't need to block this PR
robert-brunel
force-pushed
the
cardinality-index
branch
2 times, most recently
from
May 15, 2026 10:58
ba75f8b to
b4fdc77
Compare
* Introduce a `CardinalityFunctionKeyExpression` to make it possible to
define indexes with a `function("cardinality", …)` key expression.
* In `MaterializedViewIndexGenerator`, add the necessary logic to
convert `CardinalityValue` into a key expression.
For a nullable ARRAY field, the key expression produced from a
`CARDINALITY(int_arr)` SQL expression will look as follows:
function("cardinality",
field("int_arr").nest(field("values", Concatenate)))
The use of the Concatenate fan-out type currently runs into some gaps
in the code that we also fix with this PR.
Testing:
* Integration tests in `arrays_cardinality.yamsql`.
* Unit tests in `IndexTest.java` and `KeyExpressionTest.java`.
robert-brunel
force-pushed
the
cardinality-index
branch
from
May 15, 2026 12:20
b4fdc77 to
a878403
Compare
📊 Metrics Diff Analysis ReportSummary
ℹ️ About this analysisThis automated analysis compares query planner metrics between the base branch and this PR. It categorizes changes into:
The last category in particular may indicate planner regressions that should be investigated. New QueriesCount of new queries by file:
|
alecgrieser
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CardinalityFunctionKeyExpressionto make it possible to define indexes with afunction("cardinality", …)key expression.MaterializedViewIndexGenerator, add the necessary logic to convertCardinalityValueinto a key expression.For a nullable ARRAY field, the key expression produced from a
CARDINALITY(int_arr)SQL expression will look as follows:The use of the Concatenate fan-out type currently runs into some gaps in the code that we also fix with this PR.
Testing:
arrays_cardinality.yamsql.IndexTest.javaandKeyExpressionTest.java.