Skip to content

[SPARK-55317][SQL] Add SequentialUnion logical plan node and planning rule#54098

Closed
ericm-db wants to merge 8 commits intoapache:masterfrom
ericm-db:sequential-union-logical-node
Closed

[SPARK-55317][SQL] Add SequentialUnion logical plan node and planning rule#54098
ericm-db wants to merge 8 commits intoapache:masterfrom
ericm-db:sequential-union-logical-node

Conversation

@ericm-db
Copy link
Contributor

@ericm-db ericm-db commented Feb 2, 2026

What changes were proposed in this pull request?

This PR introduces the SequentialUnion logical plan node, which enables sequential processing of multiple streaming sources. Unlike the existing Union operator that processes all children concurrently, SequentialUnion processes each child source to completion before moving to the next.

The plan is for this logical operator to act as a placeholder for future consumption by the physical planning process to use specialized execution operators; there won't be a physical SequentialUnion mapping 1:1 to this logical operator.

Key changes:

  • Added SequentialUnion case class extending UnionBase in basicLogicalOperators.scala
  • Supports byName and allowMissingCol parameters for schema compatibility
  • Includes flatten() method to handle nested SequentialUnion nodes (enabling chaining)
  • Validates minimum 2 children and parameter constraints
  • Added comprehensive test suite in SequentialUnionSuite.scala

This is the foundational logical plan component. Execution support and user-facing APIs will be added in follow-up PRs.

Why are the changes needed?

Sequential Union enables backfill-to-live streaming scenarios where historical data must be processed completely before transitioning to live data, while preserving stateful operator state across the transition.

Example use case: Process historical Parquet data completely, then seamlessly switch to live Kafka streaming - all within a single query that maintains aggregations, watermarks, and deduplication state.
This pattern is not currently possible with the existing Union operator, which processes all sources concurrently.

Does this PR introduce any user-facing change?

No. This PR only adds the internal logical plan node. No user-facing APIs or behavior changes are introduced yet.

How was this patch tested?

Added new test suite SequentialUnionSuite with tests covering:

  • Basic node creation and validation
  • Minimum children requirement (at least 2)
  • Output schema verification
  • byName and allowMissingCol parameter constraints
  • Flattening logic for nested SequentialUnions (single level, deeply nested, multiple nested scenarios)

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

No

@ericm-db ericm-db force-pushed the sequential-union-logical-node branch 3 times, most recently from de63f31 to 555fcdf Compare February 3, 2026 00:21
@ericm-db ericm-db changed the title [SPARK-55317] Add SequentialUnion logical plan node [SPARK-55317] Add SequentialUnion logical plan node and planning rule Feb 3, 2026
@github-actions github-actions bot added the SQL label Feb 3, 2026
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

JIRA Issue Information

=== Task SPARK-55317 ===
Summary: Introduce the SequentialUnion Logical Node
Assignee: None
Status: Open
Affected: ["4.2.0"]


This comment was automatically generated by GitHub Actions

@ericm-db ericm-db force-pushed the sequential-union-logical-node branch 2 times, most recently from 2b62f92 to 71f685e Compare February 3, 2026 19:18
Add SequentialUnion logical plan node for sequential source processing.
Unlike Union which processes all children concurrently, SequentialUnion
processes each child source sequentially, enabling backfill-to-live
streaming scenarios.

Key features:
- Extends UnionBase for schema compatibility
- Supports flatten operation for chaining
- Validates minimum 2 children
- Compatible with byName and allowMissingCol parameters

This is the first step in implementing Sequential Union support,
providing the logical plan foundation for the execution engine.
### What changes were proposed in this pull request?

This PR introduces the SequentialUnion logical plan node and associated analysis rules for sequential processing of streaming sources.

Changes:
1. Added SequentialUnion logical plan node extending UnionBase
2. Added companion object with apply() and flatten() methods
3. Implemented FlattenSequentialUnion analysis rule
4. Implemented ValidateSequentialUnion analysis rule
5. Added error classes for validation failures
6. Registered analysis rules in Analyzer
7. Added comprehensive test suite for analysis rules

### Why are the changes needed?

This provides the foundational infrastructure for Sequential Union support, which enables backfill-to-live streaming scenarios. The analysis rules ensure proper plan structure (flattening nested unions) and validate constraints (all streaming sources, no nesting after flattening).

### Does this PR introduce any user-facing change?

No. This PR only adds internal logical plan infrastructure and analysis rules. No user-facing APIs are introduced.

### How was this patch tested?

Added SequentialUnionAnalysisSuite with tests for:
- Flattening logic (single level, nested, deeply nested, multiple nested)
- Validation of streaming requirements
- Validation of nesting constraints
- Error message verification using checkError framework

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

No.
@ericm-db ericm-db force-pushed the sequential-union-logical-node branch from 6c4fed3 to 2597785 Compare February 5, 2026 00:22
@HyukjinKwon HyukjinKwon changed the title [SPARK-55317] Add SequentialUnion logical plan node and planning rule [SPARK-55317][SQL] Add SequentialUnion logical plan node and planning rule Feb 5, 2026
Copy link
Contributor

@dtenedor dtenedor left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

Copy link
Contributor

@dtenedor dtenedor left a comment

Choose a reason for hiding this comment

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

LGTM, testing looks complete. Merging to master

@dtenedor dtenedor closed this in b75a329 Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants