Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Keep update statement output column's type consistent with target table's columns #41969

Conversation

LiShuMing
Copy link
Contributor

@LiShuMing LiShuMing commented Mar 1, 2024

Why I'm doing:

  • Update will fail when insert value is constant int(convert to bigint by default) and target column is int type
ERROR 1064 (HY000): type of exprs is not match slot's, expr_type=7, slot_type=5, slot_name=F_Completion backend [id=10001] [host=172.26.92.227]

What I'm doing:

  • Add castOutputColumnsTypeToTargetColumns in LogicalPlan to OptExpression like InsertPlanner.

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 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
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@LiShuMing LiShuMing requested a review from a team as a code owner March 1, 2024 07:31
@github-actions github-actions bot added the 3.2 label Mar 1, 2024
luohaha
luohaha previously approved these changes Mar 1, 2024
Signed-off-by: shuming.li <ming.moriarty@gmail.com>
kangkaisen
kangkaisen previously approved these changes Mar 4, 2024
Column column = targetTable.getColumn(colName);
Preconditions.checkState(column != null, "Column %s not found in table %s", colName,
targetTable.getName());
if (!column.getType().matchesType(outputColumn.getType())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

check the type can cast to target type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add it. But this should not happen since it will fail in the analyzer phase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add more tests.

Signed-off-by: shuming.li <ming.moriarty@gmail.com>
Copy link

sonarcloud bot commented Mar 5, 2024

Copy link

github-actions bot commented Mar 5, 2024

[FE Incremental Coverage Report]

fail : 27 / 36 (75.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/UpdatePlanner.java 27 36 75.00% [167, 224, 225, 226, 228, 229, 230, 231, 232]

Copy link

github-actions bot commented Mar 5, 2024

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@kangkaisen kangkaisen merged commit 677cf42 into StarRocks:main Mar 5, 2024
53 of 54 checks passed
Copy link

github-actions bot commented Mar 5, 2024

@Mergifyio backport branch-3.2

@github-actions github-actions bot removed the 3.2 label Mar 5, 2024
Copy link
Contributor

mergify bot commented Mar 5, 2024

backport branch-3.2

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Mar 5, 2024
…arget table's columns (#41969)

Signed-off-by: shuming.li <ming.moriarty@gmail.com>
(cherry picked from commit 677cf42)
wanpengfei-git pushed a commit that referenced this pull request Mar 5, 2024
…arget table's columns (backport #41969) (#42115)

Co-authored-by: shuming.li <ming.moriarty@gmail.com>
@LiShuMing
Copy link
Contributor Author

@mergify backport branch-3.1

Copy link
Contributor

mergify bot commented Mar 6, 2024

backport branch-3.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Mar 6, 2024
…arget table's columns (#41969)

Signed-off-by: shuming.li <ming.moriarty@gmail.com>
(cherry picked from commit 677cf42)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/sql/UpdatePlanner.java
wanpengfei-git pushed a commit that referenced this pull request Mar 6, 2024
…arget table's columns (backport #41969) (#42187)

Signed-off-by: shuming.li <ming.moriarty@gmail.com>
Co-authored-by: shuming.li <ming.moriarty@gmail.com>
caneGuy pushed a commit to caneGuy/starrocks that referenced this pull request Mar 22, 2024
wxl24life pushed a commit to wxl24life/starrocks that referenced this pull request Mar 28, 2024
…ent with target table's columns (backport StarRocks#41969) (StarRocks#42115)

Co-authored-by: shuming.li <ming.moriarty@gmail.com>
wxl24life pushed a commit to wxl24life/starrocks that referenced this pull request Apr 22, 2024
…ent with target table's columns (backport StarRocks#41969) (StarRocks#42115)

Co-authored-by: shuming.li <ming.moriarty@gmail.com>
wxl24life pushed a commit to wxl24life/starrocks that referenced this pull request Apr 22, 2024
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.

5 participants