github-actions[bot] commented on code in PR #66307:
URL: https://github.com/apache/doris/pull/66307#discussion_r3850252288
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/MetastoreEventSyncDriver.java:
##########
@@ -310,6 +332,40 @@ private void applyOne(PluginDrivenExternalCatalog catalog,
Connector connector,
}
}
+ private void dropTableConstraintsAndInvalidateMtmvs(TableNameInfo
tableNameInfo) {
+ List<TableNameInfo> affectedTables =
Env.getCurrentEnv().getConstraintManager()
+ .dropTableConstraints(tableNameInfo);
+ MTMVUtil.invalidateRewriteCachesByTableNamesBestEffort(affectedTables,
+ "after applying external table drop event for " +
tableNameInfo);
+ }
+
+ private void dropDatabaseConstraintsAndInvalidateMtmvs(String catalogName,
String dbName) {
+ List<TableNameInfo> affectedTables =
Env.getCurrentEnv().getConstraintManager()
+ .dropDatabaseConstraints(catalogName, dbName);
+ MTMVUtil.invalidateRewriteCachesByTableNamesBestEffort(affectedTables,
+ "after applying external database drop event for " +
catalogName + "." + dbName);
+ }
+
+ private boolean affectsConstraintMetadata(MetastoreChangeDescriptor
descriptor) {
+ switch (descriptor.getOp()) {
+ case REGISTER_DATABASE:
+ case UNREGISTER_DATABASE:
+ case RENAME_DATABASE:
+ case REGISTER_TABLE:
+ case UNREGISTER_TABLE:
+ case RENAME_TABLE:
+ case REFRESH_TABLE:
Review Comment:
[P1] Reconcile constraints on external schema refreshes
HMS emits the same `REFRESH_TABLE` descriptor for an in-place `ALTER_TABLE`
as for an insert, but this case only invalidates the table caches; the new
mutation guard does not update `ConstraintManager`. If an out-of-band ALTER
drops a constrained external column, the retained PK/UK/FK later resolves that
name against the refreshed table (which can fail planning), and recreating the
name can reactivate the old proof on unrelated data and enable an unsound
rewrite. The explicit plugin DROP/RENAME COLUMN path now checks this, but
metastore-driven ALTER is a separate path. Please distinguish schema-changing
refreshes or revalidate/drop affected constraints (and invalidate dependent
MTMV caches) before publishing the refreshed schema.
--
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]