Skip to content

Conversation

HeartSaVioR
Copy link
Contributor

@HeartSaVioR HeartSaVioR commented Oct 17, 2025

What changes were proposed in this pull request?

This PR proposes to support AQE in stateless streaming workloads. We have been disabling it due to the incompatibility with stateful operator, but it's arguably too restricted given shuffles are still triggered in stateless streaming workloads and stream-static join can benefit with it.

Note that AQE performs re-optimization which replans via reapplying optimization and physical planning against a logical link (optimized plan) for stage. IncrementalExecution instance may not be available during AQE re-optimization (e.g. ForeachBatch sink), hence streaming specific physical planning rules aren't compatible with AQE re-optimization. These rules are reserved for initializing stateful operators, hence stateless workloads are still safe to apply full phase of AQE.

Worth mentioning that AQE is not enabled for 1) continuous mode (and upcoming real time mode) 2) stateful workloads.

  • continuous mode (and real time mode): AQE doesn't make sense for continuous and real time mode since stages run concurrently.
  • stateful workloads: AQE can't change the number of partitions in stateful operator, and even if it's changeable, repartitioning state would cost a lot and we shouldn't decide it per batch based on specific batch's data distribution.

Why are the changes needed?

There are still various cases where stateless operators trigger shuffle (e.g. stream-static join), and these operators have the same characteristic with batch query which AQE has been battle tested and proved its usefulness for a long time.

Does this PR introduce any user-facing change?

Yes, AQE will be enabled in stateless streaming workloads. Given that AQE is set to true by default, stateless streaming queries will take effect, regardless whether the query starts with new Spark version, or being upgraded from old Spark version. This PR also updates this to the migration guide.

How was this patch tested?

Existing tests will run with AQE enabled if the query is stateless.

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

No.

@HeartSaVioR HeartSaVioR force-pushed the WIP-AQE-in-stateless-streaming-query branch from 7b77520 to bc9f672 Compare October 17, 2025 04:41
@HeartSaVioR HeartSaVioR changed the title [WIP][DO-NOT-MERGE][SPARK-XXXXX] Support AQE in stateless streaming workloads [WIP][DO-NOT-MERGE][SPARK-53941] Support AQE in stateless streaming workloads Oct 17, 2025
@HeartSaVioR
Copy link
Contributor Author

I'll update the PR description once I confirmed CI passes.

@HeartSaVioR HeartSaVioR force-pushed the WIP-AQE-in-stateless-streaming-query branch from fbec355 to 50f24f1 Compare October 17, 2025 09:53
@HeartSaVioR HeartSaVioR changed the title [WIP][DO-NOT-MERGE][SPARK-53941] Support AQE in stateless streaming workloads [SPARK-53941] Support AQE in stateless streaming workloads Oct 17, 2025
@HeartSaVioR HeartSaVioR changed the title [SPARK-53941] Support AQE in stateless streaming workloads [SPARK-53941][SS] Support AQE in stateless streaming workloads Oct 17, 2025
@HeartSaVioR
Copy link
Contributor Author

cc. @viirya @anishshri-db Please take a look. Thanks!

@HeartSaVioR
Copy link
Contributor Author

HeartSaVioR commented Oct 17, 2025

Interestingly I observed many cases where AQE was enabled in streaming workloads. Smart (or adventurous) customers changed the config in the user function of FEB sink to enforce turning on AQE, hence this had been tested in some different (unofficial) way as well.

@github-actions github-actions bot added the DOCS label Oct 17, 2025
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.

1 participant