-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Enhancement] Migrate the alter table related logic scattered everywhere to AlterJobExecutor #48637
Conversation
} finally { | ||
locker.unLockDatabase(db, LockType.WRITE); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I help you today?
} else if (alterClause instanceof CompactionClause) { | ||
String s = (((CompactionClause) alterClause).isBaseCompaction() ? "base" : "cumulative") | ||
+ " compact " + tableName + " partitions: " + ((CompactionClause) alterClause).getPartitionNames(); | ||
compactionHandler.process(alterClauses, db, olapTable); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you like to know or talk about today?
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most risky bug in this code is:
The startsWith
check for partition names assumes that ExpressionRangePartitionInfo.SHADOW_PARTITION_PREFIX
is not null, which could lead to a NullPointerException
.
You can modify the code like this:
if (partitionName != null && partitionName.startsWith(ExpressionRangePartitionInfo.SHADOW_PARTITION_PREFIX)) {
throw new SemanticException("Replace shadow partitions is not allowed");
}
//...
if (clause.getPartitionName() != null && clause.getPartitionName().startsWith(
ExpressionRangePartitionInfo.SHADOW_PARTITION_PREFIX)) {
throw new SemanticException("Deletion of shadow partitions is not allowed");
}
List<String> partitionNames = clause.getPartitionNames();
if (CollectionUtils.isNotEmpty(partitionNames)) {
boolean hasShadowPartition = partitionNames.stream()
.anyMatch(partitionName -> partitionName != null &&
partitionName.startsWith(ExpressionRangePartitionInfo.SHADOW_PARTITION_PREFIX));
if (hasShadowPartition) {
throw new SemanticException("Deletion of shadow partitions is not allowed");
}
}
a0ac867
to
b2789a8
Compare
…entAnalyzer Signed-off-by: HangyuanLiu <[email protected]>
eabf78f
to
a5d6804
Compare
…bExecutor Signed-off-by: HangyuanLiu <[email protected]>
a5d6804
to
a868999
Compare
Quality Gate passedIssues Measures |
[FE Incremental Coverage Report]✅ pass : 138 / 150 (92.00%) file detail
|
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
@Mergifyio backport branch-3.3 |
✅ Backports have been created
|
…ere to AlterJobExecutor (#48637) Signed-off-by: HangyuanLiu <[email protected]> (cherry picked from commit b0ea263) # Conflicts: # fe/fe-core/src/main/java/com/starrocks/alter/AlterJobExecutor.java # fe/fe-core/src/main/java/com/starrocks/alter/AlterJobMgr.java # fe/fe-core/src/main/java/com/starrocks/connector/hive/HiveMetadata.java # fe/fe-core/src/main/java/com/starrocks/sql/analyzer/AlterTableClauseAnalyzer.java # fe/fe-core/src/main/java/com/starrocks/sql/analyzer/AlterTableStatementAnalyzer.java # fe/fe-core/src/main/java/com/starrocks/sql/ast/AlterTableStmt.java # fe/fe-core/src/test/java/com/starrocks/alter/AlterTest.java # fe/fe-core/src/test/java/com/starrocks/connector/AlterTableTest.java
…ere to AlterJobExecutor (backport #48637) (#48794) Co-authored-by: HangyuanLiu <[email protected]>
…ere to AlterJobExecutor (StarRocks#48637) Signed-off-by: HangyuanLiu <[email protected]>
Why I'm doing:
/*
*/
What I'm doing:
Fixes #issue
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: