Skip to content

[SPARK-56729][SQL] ReplaceData and WriteDelta should implement SupportsNonDeterministicExpression#55858

Open
yadavay-amzn wants to merge 1 commit into
apache:masterfrom
yadavay-amzn:fix/SPARK-56729-nondeterministic
Open

[SPARK-56729][SQL] ReplaceData and WriteDelta should implement SupportsNonDeterministicExpression#55858
yadavay-amzn wants to merge 1 commit into
apache:masterfrom
yadavay-amzn:fix/SPARK-56729-nondeterministic

Conversation

@yadavay-amzn
Copy link
Copy Markdown

What changes were proposed in this pull request?

Have ReplaceData and WriteDelta extend SupportsNonDeterministicExpression with allowNonDeterministicExpression = true.

Why are the changes needed?

MERGE INTO queries fail with INVALID_NON_DETERMINISTIC_EXPRESSIONS when the source plan contains non-deterministic expressions (e.g. uuid(), current_timestamp(), input_file_name()). This is a regression from Spark 3.3 introduced when RewriteMergeIntoTable moved into core in 3.5.

The root cause is that ReplaceData (copy-on-write) and WriteDelta (merge-on-read) do not implement SupportsNonDeterministicExpression, so CheckAnalysis rejects them. SPARK-48871 introduced this trait for exactly this class of problem.

Does this PR introduce any user-facing change?

Yes. MERGE INTO with non-deterministic source plans on DSv2 tables (e.g. Iceberg) will no longer fail.

How was this patch tested?

Added test in AnalysisErrorSuite verifying both classes implement the trait.

Was this patch authored or co-authored using generative AI tooling?

Yes

@yadavay-amzn yadavay-amzn force-pushed the fix/SPARK-56729-nondeterministic branch 3 times, most recently from 0e27dd2 to 8007ce8 Compare May 14, 2026 02:29
…tsNonDeterministicExpression

MERGE INTO queries fail with INVALID_NON_DETERMINISTIC_EXPRESSIONS when
the source plan contains non-deterministic expressions (e.g. uuid(),
current_timestamp()). This regression was introduced in Spark 3.5 when
RewriteMergeIntoTable moved into core.

The fix has ReplaceData and WriteDelta extend
SupportsNonDeterministicExpression with allowNonDeterministicExpression=true,
which CheckAnalysis already respects.

Closes SPARK-56729
@yadavay-amzn yadavay-amzn force-pushed the fix/SPARK-56729-nondeterministic branch from 8007ce8 to 567d133 Compare May 14, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant