[SPARK-56729][SQL] ReplaceData and WriteDelta should implement SupportsNonDeterministicExpression#55692
Open
pabloggarc wants to merge 2 commits intoapache:masterfrom
Open
Conversation
…tsNonDeterministicExpression Co-authored-by: DaxterXS <DaxterXS@users.noreply.github.com>
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.
What changes were proposed in this pull request?
ReplaceDataandWriteDeltanow implement theSupportsNonDeterministicExpressiontrait (introduced in SPARK-48871). This fixesINVALID_NON_DETERMINISTIC_EXPRESSIONSerrors when runningMERGE INTOon DSv2 tables (e.g. Apache Iceberg) where the source plan contains non-deterministic expressions such asuuid(),current_timestamp(), orinput_file_name().Why are the changes needed?
In Spark 3.5,
RewriteMergeIntoTablewraps the source plan in anExistssubquery stored asgroupFilterConditiononReplaceData. If the source plan contains any non-deterministic expression, theExistsbecomes non-deterministic andCheckAnalysisrejects the query. TheSupportsNonDeterministicExpressiontrait was introduced in SPARK-48871 for exactly this situation, but was never applied toReplaceDataorWriteDelta. This is a regression from Spark 3.3, where these queries worked correctly.Root cause analysis by @DaxterXS in apache/iceberg#14585. Multiple users affected across AWS Glue 4/5 with Iceberg 1.7–1.10.
Does this PR introduce any user-facing change?
Yes.
MERGE INTOqueries with non-deterministic expressions in the source plan will no longer fail withINVALID_NON_DETERMINISTIC_EXPRESSIONS.How was this patch tested?
Added unit tests in
AnalysisErrorSuiteverifying thatReplaceDataandWriteDeltaimplementSupportsNonDeterministicExpression.Was this patch authored or co-authored using generative AI tooling?
No.