Skip to content

[Spark Runner] Prepare Spark 3 structured-streaming to shared base, adopt Flink-style version overrides#38233

Open
tkaymak wants to merge 1 commit intoapache:masterfrom
tkaymak:spark-refactor-base
Open

[Spark Runner] Prepare Spark 3 structured-streaming to shared base, adopt Flink-style version overrides#38233
tkaymak wants to merge 1 commit intoapache:masterfrom
tkaymak:spark-refactor-base

Conversation

@tkaymak
Copy link
Copy Markdown
Contributor

@tkaymak tkaymak commented Apr 17, 2026

What

Pure refactor of runners/spark/. Two changes:

  1. Hoist runners/spark/3/src/.../structuredstreaming/ (the only sources Spark 3 ships) into the shared runners/spark/src/. runners/spark/3/src/ is removed entirely.
  2. Replace the existing copySourceBase / useCopiedSourceSet block in runners/spark/spark_runner.gradle with the per-version source-overrides layering already used by runners/flink/flink_runner.gradle:
    • the lowest spark_major (currently 3) builds straight from the shared base;
    • higher majors get a Copy task with DuplicatesStrategy.INCLUDE that merges shared + previous majors + ./src so per-version files override.

runners/spark/3/build.gradle now sets spark_major = '3' instead of the removed copySourceBase = false flag, and gradle.properties gains spark_versions=3 (mirrors the existing flink_versions).

Why

Prepares the tree for the Spark 4 runner (#36841 / #38212), so it can land as a small overrides layer on top of this restructuring instead of duplicating the entire structured-streaming source tree.

Compatibility

Pure refactor — Spark 3's compiled output and test classpath are unchanged. The hoisted files are git-renames (verified with git diff --find-renames).

Next Step

Spark 4 follow-up branch ready: https://github.com/tkaymak/beam/tree/spark4-runner-slim

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request performs a structural refactor of the Spark runner to support a more scalable multi-version build architecture. By centralizing the core source code and implementing a layered override system for version-specific logic, the repository is now better prepared for the upcoming integration of Spark 4 without requiring extensive code duplication.

Highlights

  • Source Code Hoisting: Moved all source files from runners/spark/3/ to the shared runners/spark/src/ directory, effectively removing the version-specific subdirectory.
  • Build System Refactoring: Replaced the legacy copySourceBase mechanism in spark_runner.gradle with a Flink-style layering approach that merges shared and version-specific sources.
  • Configuration Updates: Updated gradle.properties to include spark_versions and adjusted runners/spark/3/build.gradle to use the new spark_major property.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@tkaymak tkaymak changed the title [Spark Runner] Hoist Spark 3 structured-streaming to shared base, adopt Flink-style version overrides [Spark Runner] Prepare Spark 3 structured-streaming to shared base, adopt Flink-style version overrides Apr 17, 2026
@tkaymak
Copy link
Copy Markdown
Contributor Author

tkaymak commented Apr 17, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements a version-specific source override mechanism for Spark runners, similar to the existing Flink runner implementation. It introduces logic in spark_runner.gradle to merge shared base sources with version-specific overrides into a single directory for compilation. The review feedback suggests improving the robustness of version comparison to handle multi-digit version numbers, simplifying the override detection logic using list indices, and ensuring that local source directories are consistently included even for the base Spark version.

Comment thread runners/spark/spark_runner.gradle Outdated
Comment thread runners/spark/spark_runner.gradle Outdated
Comment thread runners/spark/spark_runner.gradle
@tkaymak tkaymak force-pushed the spark-refactor-base branch from a7a019d to b391eec Compare April 17, 2026 16:53
@tkaymak
Copy link
Copy Markdown
Contributor Author

tkaymak commented Apr 17, 2026

Force-pushed the updated commit after review comments by Gemini.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a per-version source override mechanism for Spark runners, enabling higher Spark versions to merge shared base code with version-specific overrides. Key changes involve updates to gradle.properties and the Spark runner's build configuration to manage merged source sets. A review comment recommends a more robust and idiomatic Gradle configuration by using TaskProvider directly within srcDirs to automatically manage task dependencies.

Comment thread runners/spark/spark_runner.gradle Outdated
…pt Flink-style version overrides

Move runners/spark/3/src/.../structuredstreaming/ (the only sources Spark 3
shipped) into the shared runners/spark/src/, and replace the existing
copySourceBase block in runners/spark/spark_runner.gradle with the
per-version source-overrides layout used by runners/flink/flink_runner.gradle:
the lowest spark_major builds straight from the shared base; higher majors
get a Copy task with DuplicatesStrategy.INCLUDE that merges shared +
previous majors + ./src so per-version files override.

Pure refactor; Spark 3's compiled output is unchanged. Prepares the tree
for the Spark 4 runner (apache#36841 / apache#38212), which lands as a small
overrides layer on top.
@tkaymak tkaymak force-pushed the spark-refactor-base branch from b391eec to b6629d1 Compare April 17, 2026 17:01
@tkaymak
Copy link
Copy Markdown
Contributor Author

tkaymak commented Apr 17, 2026

Followed the last open comment by @gemini-code-assist — applied the fix.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Thanks for the update, @tkaymak. The revised Gradle configuration looks much cleaner and correctly leverages Gradle's task dependency auto-wiring. It's great to see the removal of the manual dependsOn blocks and null-guards. I agree that aligning runners/flink/flink_runner.gradle is a good candidate for a follow-up, but keeping it out of scope for this PR is the right call to maintain focus. The changes look solid.

@tkaymak
Copy link
Copy Markdown
Contributor Author

tkaymak commented Apr 17, 2026

assign set of reviewers

@github-actions
Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @Abacn added as fallback since no labels match configuration

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants