Skip to content

[BugFix] Merge access groups in setUnnest to fix BE SIGSEGV with stac…#75012

Open
xhumanoid wants to merge 1 commit into
StarRocks:mainfrom
xhumanoid:fix-merge-unnest-planner
Open

[BugFix] Merge access groups in setUnnest to fix BE SIGSEGV with stac…#75012
xhumanoid wants to merge 1 commit into
StarRocks:mainfrom
xhumanoid:fix-merge-unnest-planner

Conversation

@xhumanoid

Copy link
Copy Markdown
Contributor

…ked UNNESTs on the same array column

Merge access paths into the input column's access group instead of overwriting.

Multiple UNNEST operators may share the same input array column (e.g. UNNEST(a), UNNEST(a)),
and each one's downstream consumers may need different subfields of the array element.

A hard put would drop access paths recorded by earlier UNNESTs and cause the scan to
prune subfields that are still needed, leading to BE crashes when reading missing fields.

Fixes #issue

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.1
    • 4.0
    • 3.5

…ked UNNESTs on the same array column

Signed-off-by: Aliaksei Dziomin <diominay@gmail.com>
@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@github-actions github-actions Bot requested a review from satanson June 18, 2026 09:59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84d0a853c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

System.out.println("PLAN: " + plan);
// After fix: both c2_sub1 (used by t1.c2_sub1 in WHERE) and c2_sub2 (used by t2.c2_sub2) must
// be retained in the pruned type, otherwise BE crashes when reading the missing field.
assertVerbosePlanContains(sql, "[ARRAY<struct<c2_sub1 int(11), c2_sub2 int(11)>>]");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Include backticks in the expected pruned type

When this test runs, the verbose plan formats complex types through ArrayType/StructType.toString(), and struct field names are emitted with backticks; the existing assertions in this class for the same array_struct_nest.c2 type also expect struct<c2_sub1 ...>. This new expected substring omits those backticks, so a corrected plan that retains both fields still will not contain this string and the added FE unit test will fail in CI.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will update

"from array_struct_nest, unnest(c2) as t(t1), unnest(c2) as tt(t2) " +
"where t1.c2_sub1 = 5";
String plan = getVerboseExplain(sql);
System.out.println("PLAN: " + plan);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will remove it in next commit

@github-actions

Copy link
Copy Markdown
Contributor

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

@github-actions

Copy link
Copy Markdown
Contributor

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

3 participants