Skip to content

[#36841] Add streaming dispatch seam to the Spark Structured Streaming runner - #39906

Merged
Abacn merged 1 commit into
apache:masterfrom
tkaymak:spark4-streaming-slice1-dispatch-seam
Aug 28, 2026
Merged

[#36841] Add streaming dispatch seam to the Spark Structured Streaming runner#39906
Abacn merged 1 commit into
apache:masterfrom
tkaymak:spark4-streaming-slice1-dispatch-seam

Conversation

@tkaymak

@tkaymak tkaymak commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

First slice of the Spark 4 Structured Streaming work, split out of the POC #39576 as announced there. Addresses #36841.

This prepares the structured streaming runner for a streaming translator without changing batch behavior on either Spark version.

  • Adds PipelineTranslatorFactory, the seam the Spark 4 module will shadow to dispatch streaming pipelines. The shared base rejects streaming with a clear message instead of the previous generic checkArgument.
  • Opens up EvaluationContext (non final, protected constructor, leaves()) and adds a no-op stop() so a streaming context can override evaluation later.
  • Adds a createEvaluationContext hook to PipelineTranslator and skips the persist and lineage breaking optimizations for streaming datasets.
  • Plumbs the EvaluationContext into SparkStructuredStreamingPipelineResult so cancel() can stop a running streaming query.
  • Defaults the state store provider to RocksDB, required by Spark 4 transformWithState and inert for batch.
  • Adds the watermarkDelayMillis, maxRecordsPerMicroBatch, maxBatchDurationMillis and streamingStopAfterIdleBatches options.
  • Narrows the Spark 4 test source override exclude to the legacy DStream package. The previous glob also matched structuredstreaming and would have silently dropped structured streaming tests.

No behavior change for Spark 3, proven by the full :runners:spark:3:test suite (220 tests, 0 failures) and :runners:spark:4:test (196 tests, 0 failures) locally on JDK 17, plus spotless, checkstyle and a live ErrorProne compile.

The end to end evidence that this seam carries a working streaming runner is in draft #39576. Remaining slices, in order: Kryo registrations, the DataSourceV2 unbounded source, the state and timer bridge on transformWithState, and the translators with the end to end tests.

R: @Abacn

Prepares the structured streaming runner for a Spark 4 streaming
translator without changing batch behavior.

- Add PipelineTranslatorFactory, the seam the Spark 4 module shadows to
  dispatch streaming pipelines. The shared base rejects streaming with a
  clear message instead of the previous generic checkArgument.
- Open up EvaluationContext (non final, protected ctor, leaves()) and add
  a no-op stop() so a streaming context can override evaluation.
- Add a createEvaluationContext hook to PipelineTranslator and skip the
  persist and lineage breaking optimizations for streaming datasets.
- Plumb the EvaluationContext into SparkStructuredStreamingPipelineResult
  so cancel() can stop a running streaming query.
- Default the state store provider to RocksDB, required by Spark 4
  transformWithState and inert for batch.
- Add watermarkDelayMillis, maxRecordsPerMicroBatch, maxBatchDurationMillis
  and streamingStopAfterIdleBatches options.
- Narrow the Spark 4 test source override exclude to the legacy DStream
  package. The previous glob also matched structuredstreaming and would
  have silently dropped the structured streaming tests.
@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).

@Abacn Abacn 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.

Thanks! LGTM as the first change is pretty straightfoward

FYI #39899 is updating Spark runner roadmap based on your PoC PR #39576

@Abacn
Abacn merged commit d7557af into apache:master Aug 28, 2026
20 checks passed
// Note: deliberately NOT named getMaxRecordsPerBatch. The legacy Spark runner's
// SparkPipelineOptions already declares Long getMaxRecordsPerBatch(); a same-name getter with a
// different return type breaks proxy generation for every registered PipelineOptions interface.
@Description(

@Abacn Abacn Aug 28, 2026

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.

If Spark structured streaming runner does not use the legacy "getMaxRecordsPerBatch", we can use the same existing pipeline option. This make user migration effort (from legacy Spark to Spark streaming runner) smoothier. Long return type should be fine.

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