[spark] Refactor BatchWrite subclasses into base logic + per-version wrappers#7723
Open
kerwin-zk wants to merge 1 commit intoapache:masterfrom
Open
[spark] Refactor BatchWrite subclasses into base logic + per-version wrappers#7723kerwin-zk wants to merge 1 commit intoapache:masterfrom
kerwin-zk wants to merge 1 commit intoapache:masterfrom
Conversation
b4569e5 to
d274193
Compare
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.
Purpose
Follow-up of #7648 (Spark 4.1 module) and a sibling of #7721. After landing the reverse-shim layout, two of the files under
paimon-spark-4.0/src/mainonly existed as shadows because their compilation unit defined a Scala class thatextends BatchWrite. Spark 4.1 added a default methodBatchWrite.commit(WriterCommitMessage[], WriteSummary)whoseWriteSummaryparameter type does not exist on Spark 4.0; a class compiled against 4.1 that mixes inBatchWritecarries the inheritedcommit(.., WriteSummary)signature in its method table, which JVMObjectStreamClass.getPrivateMethodlazy-links during Spark task serialization and crashes 4.0 withClassNotFoundException: WriteSummary.This PR refactors both affected classes into the same base + per-version wrapper pattern:
PaimonBatchWrite(used by V2 writes)FormatTableBatchWrite(used byFormatTableV2 writes — was previously aprivate case classinsidePaimonFormatTable.scala)For each, the body lives in a new abstract base in
paimon-spark-commonthat deliberately does not extendBatchWrite(renamed protected helpers:commitMessages,abortMessages,createPaimonDataWriterFactory,createFormatTableDataWriterFactory). Each per-version module (paimon-spark3-common,paimon-spark4-common,paimon-spark-4.0/src/main) ships a thin wrapper that mixes inBatchWriteand forwards the fourBatchWritemethods to the base helpers. Routing happens through two newSparkShimfactories so each Spark version's scalac compiles the rightextends BatchWritemixin.The Spark 4.0 shadow of
PaimonFormatTable.scalais no longer needed and is deleted; only the new thinFormatTableBatchWrite.scalawrapper remains underpaimon-spark-4.0/src/main.Tests
CI
API and Format
No new public API. Two internal factories added to
org.apache.spark.sql.paimon.shims.SparkShim:createPaimonBatchWrite(table, writeSchema, dataSchema, overwritePartitions, copyOnWriteScan)createFormatTableBatchWrite(table, overwriteDynamic, overwritePartitions, writeSchema)Documentation
No user-facing changes.