feat: Mark array_compact as Compatible and improve test coverage#3889
Open
andygrove wants to merge 2 commits intoapache:mainfrom
Open
feat: Mark array_compact as Compatible and improve test coverage#3889andygrove wants to merge 2 commits intoapache:mainfrom
andygrove wants to merge 2 commits intoapache:mainfrom
Conversation
The CometArrayCompact serde was incorrectly marked as Incompatible(None). On Spark 3.x, tests pass without allowIncompatible, confirming it matches Spark behavior. On Spark 4.0, ArrayCompact is a RuntimeReplaceable that rewrites to ArrayFilter before reaching this serde. Also expands SQL file test coverage to include string, double, and nested array element types, and upgrades existing tests from spark_answer_only to query mode to assert native execution.
Spark 4.0 wraps ArrayCompact's replacement in KnownNotContainsNull, a TaggingExpression that marks containsNull=false in the schema but has no runtime effect. Pass through to the child expression so that array_compact runs natively on Spark 4.0 instead of falling back.
kazuyukitanimura
approved these changes
Apr 3, 2026
| object CometArrayCompact extends CometExpressionSerde[Expression] { | ||
|
|
||
| override def getSupportLevel(expr: Expression): SupportLevel = Incompatible(None) | ||
| override def getSupportLevel(expr: Expression): SupportLevel = Compatible() |
Contributor
There was a problem hiding this comment.
I think we can remove getSupportLevel entirely
Contributor
|
I think we will need #3796 as well |
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.
Which issue does this PR close?
Improves test coverage and correctness of
array_compactsupport level.Rationale for this change
CometArrayCompact.getSupportLevelreturnedIncompatible(None), but this was incorrect:allowIncompatible, confirming the implementation matches Spark behavior.ArrayCompactis aRuntimeReplaceablethat Spark rewrites toArrayFilter(child, IsNotNull(lambda))before it reaches Comet's serde, soCometArrayCompactis never invoked. TheCometArrayFilterserde already handles this case asCompatible().The test coverage was also limited to integer arrays only.
What changes are included in this PR?
CometArrayCompact.getSupportLevelfromIncompatible(None)toCompatible()array_compact.sqltest coverage:spark_answer_onlytoquerymode to assert native executionConfigMatrixfor dictionary encodingHow are these changes tested?
SQL file tests in
array_compact.sqlrun viaCometSqlFileTestSuite. All tests pass.