Spark: Allow overriding row-level operation mode via session config - #18202
Open
zhang-arvin wants to merge 1 commit into
Open
zhang-arvin wants to merge 1 commit into
zhang-arvin wants to merge 1 commit into
Conversation
zhang-arvin
force-pushed
the
fix/18162-session-row-level-mode
branch
from
September 22, 2026 03:33
7f5771c to
2cd8bd1
Compare
zhang-arvin
force-pushed
the
fix/18162-session-row-level-mode
branch
from
September 22, 2026 03:38
2cd8bd1 to
aa41fda
Compare
zhang-arvin
force-pushed
the
fix/18162-session-row-level-mode
branch
2 times, most recently
from
September 22, 2026 03:46
aca4df9 to
d4017fb
Compare
…n config
Adds spark.sql.iceberg.row-level-mode, which lets a Spark session select the
row-level operation mode (copy-on-write or merge-on-read) for DELETE, UPDATE
and MERGE without changing any table property.
Priority: session config > write.{delete,update,merge}.mode table property >
copy-on-write default. When the session config is not set, behaviour is
unchanged.
The resolution mirrors spark.sql.iceberg.distribution-mode, which already
overrides the per-command write.*.distribution-mode table properties.
Generated-by: Hermes Agent (deepseek-v4.1-flash)
zhang-arvin
force-pushed
the
fix/18162-session-row-level-mode
branch
from
September 22, 2026 04:48
d4017fb to
fd95180
Compare
This branch has not been deployed
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.
Fixes #18162
What
Adds a new Spark session configuration
spark.sql.iceberg.row-level-modethat lets a Spark session pick the row-level operation mode (copy-on-write vs merge-on-read) forDELETE,UPDATEandMERGEwithout changing any table property.Accepted values are
copy-on-writeandmerge-on-read; the value is parsed with the existingRowLevelOperationMode.fromName, so an invalid value fails fast withUnknown row-level operation mode: <value>.Priority
When the session config is not set, behaviour is byte-for-byte identical to before — the table property is consulted, and the hard-coded
copy-on-writedefault applies when the table property is absent. Only when the session config is present does the per-command table property get skipped.How
SparkRowLevelOperationBuilderalready resolves the mode per command from the table properties. It now readsspark.conf().get(SparkSQLProperties.ROW_LEVEL_OPERATION_MODE, null)and, when non-null, uses it in preference to the table property. This mirrors how a singlespark.sql.iceberg.distribution-modesession key overrides the per-commandwrite.(delete|update|merge).distribution-modetable properties.The property is added to
SparkSQLPropertiesnext to the existingDISTRIBUTION_MODEkey.Tests
New
TestSessionRowLevelOperationMode(spark-extensions), covering:testSessionModeOverridesTableProperties— the table is explicitly configured for copy-on-write on all three commands, the session is set tomerge-on-read;DELETE/UPDATE/MERGEmust all produce delete files (merge-on-read) rather than rewritten data files.testTablePropertiesUsedWhenSessionModeIsNotSet— with the session key unset, the copy-on-write table properties still win for all three commands, and no delete files are added.The new test runs against the existing parameter matrix (Hive/REST catalog, ORC/PARQUET/AVRO, v2/v3 format, local/distributed planning).
Notes for reviewers
spark.conf().get(key, null)is used rather thanSparkConfParserbecause the Spark option parser'ssessionConfapplies to write options keyed byspark.sql.iceberg.*; the row-level operation builder has no write-option map to feed it. Happy to switch toSparkConfParserif you'd prefer a single parsing path — it would mean threading the session conf into the builder'smoderesolution.docs/spark-configuration.md); let me know if you want it documented there as part of this PR.AI Disclosure
spark.sql.iceberg.row-level-modewith session > table property > default precedence for DELETE/UPDATE/MERGE, plus tests proving the session key wins and that unset behaviour is unchanged.