Skip to content

[MINOR] Clean up Spark 3.2 / 3.1-era compat leftovers in non-CH modules#12543

Open
LuciferYang wants to merge 2 commits into
apache:mainfrom
LuciferYang:gluten-minor-non-ch-spark32-leftovers
Open

[MINOR] Clean up Spark 3.2 / 3.1-era compat leftovers in non-CH modules#12543
LuciferYang wants to merge 2 commits into
apache:mainfrom
LuciferYang:gluten-minor-non-ch-spark32-leftovers

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Follow-up to #12525 (which cleaned up doc / velox / SparkJvmOptions leftovers) and #12541 (CH-side workarounds). This picks up the remaining Spark 3.1 / 3.2-era leftovers in non-ClickHouse modules.

Comment-only fixes

  • gluten-substrait/.../WriteFilesExecTransformer.scala: comment updated from "Spark3.2/3.3/3.4" to "Spark 3.3/3.4", with an extra sentence clarifying that Spark 3.5 strips these fields natively via SPARK-43123. Manual cleanup is still needed for the 3.3/3.4 branches (SPARK-43123 was not backported), so the code path stays.
  • gluten-arrow/.../ArrowColumnarBatch.scala: rewrite the class docstring. The old claim "Spark-3.2 declares ColumnarBatch as final" is factually wrong on every currently supported branch (public class ColumnarBatch implements AutoCloseable on 3.3 / 3.4 / 3.5 / 4.0 / 4.1). Replaced with a factual note that this is a historical fork kept standalone to preserve the writable-column contract.
  • gluten-celeborn/.../CelebornShuffleManager.java: drop the "Added in SPARK-32055, for Spark 3.1 and above" comment. That condition holds on every currently supported Spark version, so the note has no signal.

Small code refactors

  • backends-velox/.../velox/VeloxFormatWriterInjects.scala: drop the "Do NOT add override keyword for compatibility on spark 3.1" comment and add the override keyword to the anonymous OutputWriter.path(). Spark's OutputWriter.path(): String is abstract on every supported branch, so override is legal there and now matches the neighbouring override def close().
  • tools/gluten-it/common/.../SparkJvmOptions.java: replace the reflection-based lookup of org.apache.spark.launcher.JavaModuleOptions with a direct JavaModuleOptions.defaultModuleOptions() call. The class is public with a public static defaultModuleOptions() method, documented @since 3.3.0, and reachable via the spark-launcher transitive dep of spark-core on every supported branch. The Spark 3.2 ClassNotFoundException fallback was already removed by [MINOR] Align supported Spark version references #12525; this eliminates the remaining reflection scaffolding.

No behavior change on any supported Spark version.

How was this patch tested?

  • ./build/mvn -Pbackends-velox -Pspark-3.5 -pl backends-velox -am test-compile -DskipTests: SUCCESS
  • ./build/mvn -Pbackends-velox -Pspark-3.3 -pl backends-velox -am test-compile -DskipTests: SUCCESS
  • ./build/mvn -Pbackends-velox -Pspark-3.5 -pl gluten-arrow -am test-compile -DskipTests: SUCCESS
  • ./build/mvn -Pbackends-velox -Pspark-3.5 -pl gluten-substrait -am test-compile -DskipTests: SUCCESS
  • ./build/mvn -Pbackends-velox -Pspark-3.5 -Pceleborn -pl gluten-celeborn -am test-compile -DskipTests: SUCCESS
  • javac -cp spark-launcher_2.12-3.3.1.jar tools/gluten-it/common/.../SparkJvmOptions.java: SUCCESS
  • javac -cp spark-launcher_2.12-3.5.7.jar tools/gluten-it/common/.../SparkJvmOptions.java: SUCCESS
  • javac -cp spark-launcher_2.13-4.1.0-SNAPSHOT.jar tools/gluten-it/common/.../SparkJvmOptions.java: SUCCESS
  • Ran the compiled SparkJvmOptions#main against spark-launcher_2.12-3.5.7 and confirmed the output matches Spark's JavaModuleOptions.defaultModuleOptions() string.
  • Cross-checked upstream Spark on branch-3.3 / branch-3.4 / branch-3.5 / branch-4.0 / branch-4.1:
    • ColumnarBatch is public class ColumnarBatch implements AutoCloseable (non-final) on all branches.
    • OutputWriter.path(): String is abstract on all branches.
    • JavaModuleOptions.defaultModuleOptions() exists as public static on all branches.

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

Generated-by: Claude claude-opus-4-7

Now that Gluten supports only Spark 3.3+, drop a handful of comment and
code leftovers referring to Spark 3.1 / 3.2:

* `gluten-substrait/.../WriteFilesExecTransformer.scala`: comment updated
  from "Spark3.2/3.3/3.4" to "Spark 3.3/3.4", with an extra sentence
  clarifying that Spark 3.5 strips these fields natively via SPARK-43123.
  Manual cleanup is still needed for the 3.3/3.4 branches.

* `gluten-arrow/.../ArrowColumnarBatch.scala`: rewrite the class docstring.
  The old claim "Spark-3.2 declares ColumnarBatch as final" is factually
  wrong on every currently supported branch (`public class ColumnarBatch
  implements AutoCloseable` on 3.3/3.4/3.5/4.0/4.1). Replaced with a
  factual note that this is a historical fork kept standalone to preserve
  the writable-column contract.

* `gluten-celeborn/.../CelebornShuffleManager.java`: drop the "Added in
  SPARK-32055, for Spark 3.1 and above" comment. That condition holds on
  every currently supported Spark version, so the note has no signal.

* `backends-velox/.../velox/VeloxFormatWriterInjects.scala`: drop the
  "Do NOT add override keyword for compatibility on spark 3.1" comment
  and add the `override` keyword to the anonymous `OutputWriter.path()`.
  Spark's `OutputWriter.path(): String` is abstract on every supported
  branch, so `override` is legal there and now matches the neighbouring
  `override def close()`.

* `tools/gluten-it/common/.../SparkJvmOptions.java`: replace the
  reflection-based lookup of `org.apache.spark.launcher.JavaModuleOptions`
  with a direct `JavaModuleOptions.defaultModuleOptions()` call. The
  class is `public` with a public static `defaultModuleOptions()` method,
  documented `@since 3.3.0`, and reachable via the `spark-launcher`
  transitive dep of `spark-core` on every supported branch. The Spark 3.2
  `ClassNotFoundException` fallback was already removed by apache#12525; this
  eliminates the remaining reflection scaffolding.

No behavior change on any supported Spark version.
Copilot AI review requested due to automatic review settings July 17, 2026 06:11
@github-actions github-actions Bot added CORE works for Gluten Core VELOX RSS TOOLS labels Jul 17, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Cleans up remaining Spark 3.1/3.2 compatibility leftovers (mostly comments + small refactors) across non-ClickHouse modules, aligning the codebase with the currently supported Spark versions (3.3+).

Changes:

  • Simplifies SparkJvmOptions by replacing reflection with a direct JavaModuleOptions.defaultModuleOptions() call.
  • Removes outdated Spark-version compatibility comments and updates documentation comments to reflect current Spark behavior.
  • Adds an override modifier where it is now valid/expected on supported Spark branches.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/gluten-it/common/src/main/java/org/apache/gluten/integration/SparkJvmOptions.java Drops reflection and directly calls JavaModuleOptions.defaultModuleOptions().
gluten-substrait/src/main/scala/org/apache/gluten/execution/WriteFilesExecTransformer.scala Updates Spark-version comment and adds Spark 3.5 context for internal metadata stripping.
gluten-celeborn/src/main/java/org/apache/spark/shuffle/gluten/celeborn/CelebornShuffleManager.java Removes a now-uninformative Spark-version comment.
gluten-arrow/src/main/scala/org/apache/gluten/vectorized/ArrowColumnarBatch.scala Rewrites class Scaladoc to remove outdated/factually incorrect Spark 3.2 claim.
backends-velox/src/main/scala/org/apache/spark/sql/execution/datasources/velox/VeloxFormatWriterInjects.scala Adds override to OutputWriter.path() and removes obsolete Spark 3.1 compatibility note.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 23 to 25
public static String read() {
try {
final Class<?> clazz = Class.forName(MODULE_OPTIONS_CLASS_NAME);
final Method method = clazz.getMethod("defaultModuleOptions");
return (String) method.invoke(null);
} catch (ClassNotFoundException
| NoSuchMethodException
| InvocationTargetException
| IllegalAccessException e) {
throw new RuntimeException(
"Failed to read Spark JVM module options via "
+ MODULE_OPTIONS_CLASS_NAME
+ "#defaultModuleOptions",
e);
}
return JavaModuleOptions.defaultModuleOptions();
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the note. I don't think a guard is worth adding here:

  • spark-launcher is a compile-scope dep of spark-core on every currently supported branch (Spark 3.3 through 4.1), so JavaModuleOptions will always be on the classpath at runtime.
  • The only caller is tools/gluten-it/sbin/gluten-it.sh, which runs SparkJvmOptions against the package/target/lib directory containing the full Gluten + Spark jars — the same classpath every Gluten job uses.

A guard would trade a standard JVM linkage error for a slightly nicer message in a scenario that has no realistic way to occur; every other Gluten module already calls Spark APIs directly and would fail earlier under a hypothetical missing-spark-core setup. I'd rather match that convention.

}

// To be compatible with Spark3.2/3.3/3.4, we do cleanup spark internal metadata manually.
// To be compatible with Spark 3.3/3.4, we do cleanup spark internal metadata manually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed in bf250e9 — "we do cleanup spark..." → "we clean up Spark...".

@LuciferYang
LuciferYang marked this pull request as draft July 17, 2026 06:20
Address Copilot review feedback: "we do cleanup spark internal metadata"
reads awkwardly. Change to "we clean up Spark internal metadata".
No code change.
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@LuciferYang
LuciferYang marked this pull request as ready for review July 17, 2026 06:54
Copilot AI review requested due to automatic review settings July 17, 2026 06:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core RSS TOOLS VELOX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants