Skip to content

build: add spark-4.1 Maven profile and shim sources#4097

Open
andygrove wants to merge 3 commits intoapache:mainfrom
andygrove:spark-4.1-profile-prep
Open

build: add spark-4.1 Maven profile and shim sources#4097
andygrove wants to merge 3 commits intoapache:mainfrom
andygrove:spark-4.1-profile-prep

Conversation

@andygrove
Copy link
Copy Markdown
Member

@andygrove andygrove commented Apr 26, 2026

Which issue does this PR close?

Rationale for this change

Adds the infrastructure needed to compile Comet against Spark 4.1 (currently 4.1.1) without enabling any spark-4.1 tests in CI. This is a preparation PR that lets the bigger Spark 4.1 enablement work (diff file, full test matrix entries, plan-stability golden files, docs) land in subsequent PRs against a code base that already has the profile and shims in place.

After this PR, ./mvnw install -DskipTests -Dmaven.test.skip=true -Pspark-4.1 succeeds, and a new compile-only PR-build job verifies that on every PR.

What changes are included in this PR?

New spark-4.1 Maven profile in pom.xml and spark/pom.xml. Pins versions to match what Spark 4.1.1 itself ships with: scala.version=2.13.17, parquet.version=1.16.0, slf4j.version=2.0.17, jetty=11.0.26. The iceberg-spark-runtime artifact for Spark 4.1 isn't published yet, so the profile reuses iceberg-spark-runtime-4.0_2.13:1.10.0 until it is.

New shim source trees at spark/src/main/spark-4.1/, common/src/main/spark-4.1/, and spark/src/test/spark-4.1/, mirroring their spark-4.0 counterparts. Three 4.1-specific deltas inside the trees:

  • CometExprShim.binaryOutputStyle no longer parses BINARY_OUTPUT_STYLE as a string. Spark 4.1 made it an enumConf, so getConf already returns the enum.
  • CometEvalModeUtil.sumEvalMode reads s.evalContext.evalMode. Spark 4.1 wrapped Sum's EvalMode in a NumericEvalContext.
  • CometTypeShim.isVariantStruct wires through to VariantMetadata.isVariantStruct, matching the helper fix: fall back for shredded Variant scans on Spark 4.0 #4084 added to the spark-4.0 shim.

No-op refactors that prepare existing profiles for the new shim (these compile to identical bytecode on 3.x/4.0 today):

  • CometEvalModeUtil.sumEvalMode helper added to the spark-3.4 / spark-3.5 / spark-4.0 type shims. aggregates.scala updated to call CometEvalModeUtil.sumEvalMode(sum) instead of sum.evalMode. Lets the spark-4.1 shim provide the alternate s.evalContext.evalMode form.
  • New MapStatusHelper.scala wraps MapStatus.apply, so the three Java shuffle-writer call sites (in CometBypassMergeSortShuffleWriter and CometUnsafeShuffleWriter) don't need to see Scala default parameters. Required because Spark 4.1 added a checksumVal: Long = 0 default.
  • CometShuffleManager swaps Collections.emptyMap() for new ConcurrentHashMap[Int, OpenHashSet[Long]]() in the reflective IndexShuffleBlockResolver constructor lookup. ConcurrentHashMap is also a java.util.Map, so 3.x/4.0 still resolve; required because Spark 4.1 widened the third constructor parameter from Map to ConcurrentMap.
  • isSpark41Plus added to CometSparkSessionExtensions. Not yet referenced anywhere; lands here so downstream PRs can use it without churn.

New compile-only PR-build job in pr_build_linux.yml. Runs ./mvnw install -DskipTests -Dmaven.test.skip=true -Pspark-4.1 so the new profile keeps compiling on every PR. Sits alongside lint-java and the test matrix as an independent job. Excluded from lint-java because that job runs -Psemanticdb scalafix and semanticdb-scalac_2.13.17 is not yet published. Excluded from linux-test because Comet's existing test suites have known failures under spark-4.1 that are deferred to follow-up PRs.

Out of scope (intentionally deferred to follow-up PRs):

  • dev/diffs/4.1.1.diff for Spark SQL Tests
  • Any .github/workflows/* matrix entries that would run spark-4.1 tests (lint or unit)
  • Plan-stability golden files for 4.1 and the corresponding CometPlanStabilitySuite branch
  • Docs additions for the new-version workflow
  • Runtime-only Spark 4.1 fixes (e.g. CometNativeWriteExec FileNameSpec, REMAINDER_BY_ZERO test branching)

How are these changes tested?

Locally:

  • ./mvnw install -DskipTests -Dmaven.test.skip=true -Pspark-4.1 passes (76s reactor time).
  • ./mvnw test-compile -Pspark-4.1 passes.
  • ./mvnw test-compile -Pspark-3.5 -Pscala-2.13 and ./mvnw test-compile -Pspark-4.0 pass (verifying the no-op refactors).

CI: the new build-spark-4.1 job runs the same compile command on every PR. The existing 3.4 / 3.5 / 4.0 PR-build matrices continue to exercise the no-op refactors against those profiles.

Adds infrastructure to compile Comet against Spark 4.1 (currently 4.1.1) without enabling it in any CI workflow. After this change, ./mvnw -Pspark-4.1 succeeds locally for compile and test-compile.

Profile properties (root pom.xml and spark/pom.xml):
- scala.version 2.13.17, scala.binary.version 2.13
- spark.version 4.1.1, spark.version.short 4.1
- parquet.version 1.16.0, slf4j.version 2.0.17
- shims.majorVerSrc spark-4.1
- iceberg-spark-runtime-4.0 reused since the 4.1 artifact isn't published yet
- jetty 11.0.26 to match Spark 4.1.1's jetty.version

Shim trees (new):
- spark/src/main/spark-4.1/** and common/src/main/spark-4.1/** mirror their spark-4.0 counterparts, with two 4.1-specific deltas:
  * CometExprShim.binaryOutputStyle no longer parses BINARY_OUTPUT_STYLE as a string (Spark 4.1 made it an enumConf, so getConf returns the enum directly).
  * CometEvalModeUtil.sumEvalMode reads s.evalContext.evalMode (Spark 4.1 wraps EvalMode in a NumericEvalContext).
  * CometTypeShim.isVariantStruct wired through to VariantMetadata.isVariantStruct, matching the spark-4.0 shim that apache#4084 introduced.
- spark/src/test/spark-4.1/** mirrors the spark-4.0 test shim tree so JVM tests can compile under -Pspark-4.1.

No-op refactors that prepare existing profiles for the new shim:
- spark-3.4/3.5/4.0 CometExprShim.scala gain a CometEvalModeUtil.sumEvalMode helper that returns s.evalMode; aggregates.scala calls the helper instead of sum.evalMode directly. Behavior unchanged on 3.x/4.0; lets the spark-4.1 shim provide the alternate form.
- New MapStatusHelper.scala wraps MapStatus.apply so Java callers (CometBypassMergeSortShuffleWriter, CometUnsafeShuffleWriter) don't need to see Scala default parameters; required because Spark 4.1 added a checksumVal default param.
- CometShuffleManager swaps Collections.emptyMap() for new ConcurrentHashMap[Int, OpenHashSet[Long]]() in the reflective IndexShuffleBlockResolver constructor lookup. ConcurrentHashMap is also a java.util.Map, so 3.x/4.0 still resolve; required because Spark 4.1 widened the third constructor parameter from Map to ConcurrentMap.
- isSpark41Plus added to CometSparkSessionExtensions for downstream use; not yet referenced anywhere.

Out of scope for this PR (will land in a follow-up):
- dev/diffs/4.1.1.diff for Spark SQL Tests
- Any .github/workflows/* matrix entries for 4.1
- Plan-stability golden files for 4.1
- Docs additions
- Runtime fixes (CometNativeWriteExec FileNameSpec, REMAINDER_BY_ZERO test branching, etc.)
Adds a new build-spark-4.1 job to pr_build_linux.yml that runs ./mvnw install -DskipTests -Dmaven.test.skip=true -Pspark-4.1. Verifies that the new profile and shim trees keep compiling on every PR without enabling any spark-4.1 tests in CI.

Avoids the existing lint-java matrix because that job runs -Psemanticdb scalafix and semanticdb-scalac_2.13.17 is not yet published. Avoids the linux-test matrix because Comet's existing test suites have known failures under the spark-4.1 profile that are deferred to follow-up PRs.

The job is independent: needs only the lint gate, doesn't share artifacts with build-native, and doesn't change any other job.
GitHub Actions job IDs may only contain alphanumerics, dash, and underscore. The dot in build-spark-4.1 made the workflow invalid. Rename to build-spark-4-1 to match the dash style used elsewhere in this file. The display name (Build Spark 4.1, JDK 17) is unchanged.
@andygrove andygrove marked this pull request as ready for review April 26, 2026 17:24
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