Skip to content

Conversation

@stephen-shelby
Copy link
Contributor

@stephen-shelby stephen-shelby commented Dec 26, 2025

Why I'm doing:

PR #66517 introduced single-tablet result sink optimization in shared-data mode, but it causes ERROR 1064 (HY000): This sql plan has multi result sinks for queries like UNION with user variables.

The issue is that only the top fragment was marked with isSingleTabletGatherOutputFragment, while intermediate fragments (e.g., AGGREGATE) were still assigned to all compute nodes by the isPreferComputeNode strategy, creating multiple result sink instances.

What I'm doing:

  • Mark all non-scan fragments with isSingleTabletGatherOutputFragment flag when single-tablet optimization is triggered
  • Skip isPreferComputeNode strategy for fragments marked with isSingleTabletGatherOutputFragment

Fixes #issue
https://github.com/StarRocks/StarRocksTest/issues/10756

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
    • This pr needs auto generate documentation
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.0
    • 3.5
    • 3.4
    • 3.3

Note

Fixes single-tablet planning in shared-data mode by correctly marking gather fragments and adds regression tests.

  • In PlanFragmentBuilder, when single-tablet optimization/short-circuit applies, set isSingleTabletGatherOutputFragment on all non-ScanNode fragments instead of only the input fragment
  • Adds planner test in JoinTest to validate RESULT SINK/AGGREGATE (merge finalize) with UNION
  • Extends test_union_all_with_limit SQL tests with a duplicate-key table and a UNION over a session variable to cover result planning

Written by Cursor Bugbot for commit 7ffab44. This will update automatically on new commits. Configure here.

@stephen-shelby stephen-shelby changed the title [BugFix] Fix multi result sinks error for single-tablet queries in shared-data mode [UT] Fix multi result sinks error for single-tablet queries in shared-data mode Dec 26, 2025
@stephen-shelby stephen-shelby changed the title [UT] Fix multi result sinks error for single-tablet queries in shared-data mode [BugFix] Fix multi result sinks error for single-tablet queries in shared-data mode Dec 26, 2025
@sonarqubecloud
Copy link

@alvin-celerdata
Copy link
Contributor

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!

@github-actions
Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

@github-actions
Copy link

[FE Incremental Coverage Report]

pass : 4 / 4 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/plan/PlanFragmentBuilder.java 4 4 100.00% []

@github-actions
Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

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