Skip to content

[BugFix] Cast COALESCE children to common type in JOIN USING transformer#72338

Merged
stdpain merged 3 commits into
StarRocks:mainfrom
Hyper-FF:claude/fix-coalesce-datetime-LtTBL
Apr 30, 2026
Merged

[BugFix] Cast COALESCE children to common type in JOIN USING transformer#72338
stdpain merged 3 commits into
StarRocks:mainfrom
Hyper-FF:claude/fix-coalesce-datetime-LtTBL

Conversation

@Hyper-FF

Copy link
Copy Markdown
Contributor

Why I'm doing:

createCoalesceOperator resolved a common result type for the synthesized USING-projection COALESCE but passed the original left/right operands as children without casting, so the call's actual child types could disagree with the resolved function signature (e.g. DATETIME child under a coalesce(VARCHAR) signature). Wrap children whose type differs from the common type in an implicit CAST and look up the function with {commonType, commonType} so the signature is consistent.

What I'm doing:

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
    • 3.4

createCoalesceOperator resolved a common result type for the synthesized
USING-projection COALESCE but passed the original left/right operands as
children without casting, so the call's actual child types could disagree
with the resolved function signature (e.g. DATETIME child under a
coalesce(VARCHAR) signature). Wrap children whose type differs from the
common type in an implicit CAST and look up the function with
{commonType, commonType} so the signature is consistent.
@Hyper-FF Hyper-FF requested a review from a team as a code owner April 29, 2026 08:33
@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@github-actions github-actions Bot requested a review from satanson April 29, 2026 08:36
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ 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".

claude and others added 2 commits April 29, 2026 09:17
Covers the planner fix for createCoalesceOperator: USING-named columns
that have DATETIME on one side and VARCHAR on the other must be wrapped
in an explicit CAST to the resolved common type so the synthesized
COALESCE has well-typed children.  Verifies the queries do not error
out and that match / outer-row counts are correct.
Signed-off-by: Hyper-FF <253014618+Hyper-FF@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ 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".

@github-actions

Copy link
Copy Markdown
Contributor

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

@github-actions

Copy link
Copy Markdown
Contributor

[FE Incremental Coverage Report]

pass : 6 / 6 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/optimizer/transformer/RelationTransformer.java 6 6 100.00% []

@github-actions

Copy link
Copy Markdown
Contributor

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@stdpain stdpain merged commit cb2fd87 into StarRocks:main Apr 30, 2026
55 of 57 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

@Mergifyio backport branch-4.0

@github-actions

Copy link
Copy Markdown
Contributor

@Mergifyio backport branch-4.1

@mergify

mergify Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

backport branch-4.0

✅ Backports have been created

Details

Cherry-pick of cb2fd87 has failed:

On branch mergify/bp/branch-4.0/pr-72338
Your branch is up to date with 'origin/branch-4.0'.

You are currently cherry-picking commit cb2fd87fcb.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   fe/fe-core/src/test/java/com/starrocks/sql/plan/JoinTest.java
	new file:   test/sql/test_join/R/test_full_outer_join_using_mismatched_types.sql
	new file:   test/sql/test_join/T/test_full_outer_join_using_mismatched_types.sql

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   fe/fe-core/src/main/java/com/starrocks/sql/optimizer/transformer/RelationTransformer.java

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify

mergify Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

backport branch-4.1

✅ Backports have been created

Details

wanpengfei-git pushed a commit that referenced this pull request Apr 30, 2026
…mer (backport #72338) (#72371)

Signed-off-by: stdpain <34912776+stdpain@users.noreply.github.com>
Co-authored-by: Hyper-FF <253014618+Hyper-FF@users.noreply.github.com>
Co-authored-by: stdpain <34912776+stdpain@users.noreply.github.com>
wanpengfei-git pushed a commit that referenced this pull request Apr 30, 2026
…mer (backport #72338) (#72372)

Signed-off-by: Hyper-FF <253014618+Hyper-FF@users.noreply.github.com>
Co-authored-by: Hyper-FF <253014618+Hyper-FF@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
robd003 pushed a commit to robd003/starrocks that referenced this pull request May 6, 2026
…mer (StarRocks#72338)

Signed-off-by: Hyper-FF <253014618+Hyper-FF@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
xiangguangyxg pushed a commit to xiangguangyxg/starrocks that referenced this pull request May 7, 2026
…mer (StarRocks#72338)

Signed-off-by: Hyper-FF <253014618+Hyper-FF@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: xiangguangyxg <xiangguangyxg@gmail.com>
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.

6 participants