[BugFix] fix partial update failure due to column name case (backport #53656) #53686
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why I'm doing:
Partial update fail in this case: #53655
This is because in UpdatePlaner.java:
!updateStmt.isAssignmentColumn(column.getName())
is case-sensitively, so if the update column name are not same as which it was defined when create table, it will generate wrong plan. E.g.If you update
salary
instead ofSalary
, it will fail withnumber of exprs is not same with slots backend
.What I'm doing:
Update planner treats column names case-sensitively, which can lead to incorrect execution plans.
This pull request introduces improvements to the handling of column updates in SQL statements and adds corresponding test cases. The most important changes include modifying how assignment columns are stored, adding a new test method for partial updates, and creating new test scripts for upper-case partial updates.
Enhancements to column updates:
fe/fe-core/src/main/java/com/starrocks/sql/ast/UpdateStmt.java
: Changed theassignmentColumns
from aHashSet
to aTreeSet
with case-insensitive ordering to ensure consistent handling of column names.New test cases for partial updates:
fe/fe-core/src/test/java/com/starrocks/sql/plan/UpdatePlanTest.java
: Added a new test methodtestColumnPartialUpdate
to verify the behavior of partial updates in different scenarios.New test scripts for upper-case partial updates:
test/sql/test_partial_update_column_mode/R/test_upper_case_partial_update
: Added a new test script to validate partial updates with upper-case column names. This script includes table creation, data insertion, and update operations.test/sql/test_partial_update_column_mode/T/test_upper_case_partial_update
: Added another test script with the same purpose as the previous one, ensuring thorough testing of partial updates with upper-case column names.Fixes #53655
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
This is an automatic backport of pull request [BugFix] fix partial update failure due to column name case #53656 done by Mergify.
Why I'm doing:
Partial update fail in this case: #53655
This is because in UpdatePlaner.java:
!updateStmt.isAssignmentColumn(column.getName())
is case-sensitively, so if the update column name are not same as which it was defined when create table, it will generate wrong plan. E.g.If you update
salary
instead ofSalary
, it will fail withnumber of exprs is not same with slots backend
.What I'm doing:
Update planner treats column names case-sensitively, which can lead to incorrect execution plans.
This pull request introduces improvements to the handling of column updates in SQL statements and adds corresponding test cases. The most important changes include modifying how assignment columns are stored, adding a new test method for partial updates, and creating new test scripts for upper-case partial updates.
Enhancements to column updates:
fe/fe-core/src/main/java/com/starrocks/sql/ast/UpdateStmt.java
: Changed theassignmentColumns
from aHashSet
to aTreeSet
with case-insensitive ordering to ensure consistent handling of column names.New test cases for partial updates:
fe/fe-core/src/test/java/com/starrocks/sql/plan/UpdatePlanTest.java
: Added a new test methodtestColumnPartialUpdate
to verify the behavior of partial updates in different scenarios.New test scripts for upper-case partial updates:
test/sql/test_partial_update_column_mode/R/test_upper_case_partial_update
: Added a new test script to validate partial updates with upper-case column names. This script includes table creation, data insertion, and update operations.test/sql/test_partial_update_column_mode/T/test_upper_case_partial_update
: Added another test script with the same purpose as the previous one, ensuring thorough testing of partial updates with upper-case column names.Fixes #53655
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist: