Skip to content

fix(planner): disable project block merge in non-top-level subplans#34613

Merged
guanshengliang merged 1 commit intomainfrom
fix/proj-merge-datablock
Feb 28, 2026
Merged

fix(planner): disable project block merge in non-top-level subplans#34613
guanshengliang merged 1 commit intomainfrom
fix/proj-merge-datablock

Conversation

@JinqingKuang
Copy link
Copy Markdown
Contributor

Description

fix(planner): disable project block merge in non-top-level subplans

Issue(s)

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

Copilot AI review requested due to automatic review settings February 27, 2026 10:44
@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 refines the query planner's behavior by conditionally disabling the merging of project blocks within subplans. The change ensures that project nodes only merge data blocks when they are the root output of a top-level subplan, preventing incorrect optimizations that could lead to issues like query hangs. A new test case has been added to validate this specific behavior.

Highlights

  • Planner Logic Update: Modified the projectCanMergeDataBlock function to prevent project block merging in non-top-level subplans or when the project node is not the root output of a top-level subplan. This addresses potential issues with subplan processing.
  • Function Signature Change: Updated the projectCanMergeDataBlock and createProjectPhysiNode function signatures to include a topLevelSubplan parameter, which is derived from the subplan's level.
  • New Test Case Added: Introduced a new Python test case to specifically verify that the 'Projection Merge ResBlocks' flag is correctly set to False in the explain plan for queries involving subqueries with interval and sliding windows, confirming the fix.

🧠 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.

Changelog
  • source/libs/planner/src/planPhysiCreater.c
    • Modified projectCanMergeDataBlock to accept a topLevelSubplan boolean parameter and added logic to prevent merging if it's not a top-level subplan or has a parent.
    • Updated createProjectPhysiNode to pass the subplan's level (indicating top-level status) to projectCanMergeDataBlock.
    • Adjusted the call to createProjectPhysiNode within doCreatePhysiNode to include the pSubplan argument.
  • test/cases/13-TimeSeriesExt/03-TimeWindow/test_interval_project_merge_resblock.py
    • Added a new test file test_interval_project_merge_resblock.py to verify the correct behavior of project block merging in subqueries with interval and sliding windows.
    • Implemented a helper function _assert_projection_merge_resblock_false to parse explain plans and assert that 'Projection Merge ResBlocks' is set to False.
Activity
  • The test cases have been passed and automated.
  • There is no significant decrease in test coverage.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes an issue where project block merging in non-top-level subplans was causing interval query hangs. The fix disables the merge optimization for projection nodes that are not at the root of the top-level subplan.

Changes:

  • Modified projectCanMergeDataBlock function to accept a topLevelSubplan parameter and added logic to disallow merging when not at the top level or when the projection has a parent
  • Updated createProjectPhysiNode to pass the subplan object and determine if it's top-level based on subplan->level == 0
  • Added regression test to verify the fix by checking the explain plan output

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
source/libs/planner/src/planPhysiCreater.c Added top-level subplan check to projectCanMergeDataBlock function and updated createProjectPhysiNode signature to pass subplan
test/cases/13-TimeSeriesExt/03-TimeWindow/test_interval_project_merge_resblock.py Added regression test that verifies Projection Merge ResBlocks is set to False in explain plan

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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 disables project block merging for non-top-level subplans to fix a planner issue. The changes in planPhysiCreater.c introduce a topLevelSubplan flag to projectCanMergeDataBlock to control this behavior. The call sites are updated accordingly. A new Python test is added to verify that the Merge ResBlocks flag is correctly set to False in the EXPLAIN plan for a query with a non-terminal projection node. The logic appears sound and the test case effectively validates the fix.

@JinqingKuang JinqingKuang force-pushed the fix/proj-merge-datablock branch from e9eeaba to 00434cf Compare February 28, 2026 01:03
Copilot AI review requested due to automatic review settings February 28, 2026 01:33
@JinqingKuang JinqingKuang force-pushed the fix/proj-merge-datablock branch from 00434cf to efcd78a Compare February 28, 2026 01:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@guanshengliang guanshengliang merged commit ee441e5 into main Feb 28, 2026
18 of 20 checks passed
@guanshengliang guanshengliang deleted the fix/proj-merge-datablock branch February 28, 2026 08:06
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.

3 participants