sollhui commented on code in PR #64878:
URL: https://github.com/apache/doris/pull/64878#discussion_r3654178601
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterRoutineLoadCommand.java:
##########
@@ -344,6 +373,37 @@ private void checkPartialUpdate() throws UserException {
}
}
+ private void validateTargetTable(ConnectContext ctx, RoutineLoadJob job)
throws UserException {
+ if (job.getDataSourceType() != LoadDataSourceType.KAFKA) {
+ throw new AnalysisException("ALTER ROUTINE LOAD target table
change only supports Kafka jobs");
+ }
+ if (job.isMultiTable()) {
+ throw new AnalysisException("ALTER ROUTINE LOAD target table
change only supports single-table job");
+ }
+ String dbFullName = job.getDbFullName();
+ if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ctx,
InternalCatalog.INTERNAL_CATALOG_NAME,
+ dbFullName, targetTableName, PrivPredicate.LOAD)) {
+
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLEACCESS_DENIED_ERROR,
"LOAD",
+ ctx.getQualifiedUser(), ctx.getRemoteIP(), dbFullName + ":
" + targetTableName);
+ }
+ Database db =
Env.getCurrentInternalCatalog().getDbOrAnalysisException(dbFullName);
+ Table table = db.getTableOrAnalysisException(targetTableName);
+ if (!(table instanceof OlapTable)) {
+ throw new AnalysisException("ALTER ROUTINE LOAD target table only
supports OLAP table");
+ }
+ OlapTable olapTable = (OlapTable) table;
+ if (olapTable.isTemporary()) {
+ throw new AnalysisException("Do not support load for temporary
table " + olapTable.getDisplayName());
+ }
+ if (job.isLoadToSingleTablet()
+ && !(olapTable.getDefaultDistributionInfo() instanceof
RandomDistributionInfo)) {
+ throw new AnalysisException(
+ "if load_to_single_tablet set to true, the olap table must
be with random distribution");
+ }
+ job.validateTargetTable(db, olapTable);
Review Comment:
[P1] Validate the target with the statement effective job properties, not
the current job state. For example, if the paused job currently uses `UPSERT`,
table B is a non-MoW OLAP table, and the statement switches to B while setting
`unique_key_update_mode=UPDATE_FIXED_COLUMNS`, this call plans B as the current
`UPSERT` job and accepts it. `modifyPropertiesInternal()` then installs
`UPDATE_FIXED_COLUMNS` before assigning B, without revalidating the final
combination, so ALTER succeeds but the first resumed task fails because fixed
partial update requires MoW. Please build and validate one staged task
definition containing both the target and `analyzedJobProperties`, then publish
that same validated definition atomically. Add a negative test for this exact
combination.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]