rpuch commented on code in PR #3223:
URL: https://github.com/apache/ignite-3/pull/3223#discussion_r1495849353
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/AlterTableDropColumnCommand.java:
##########
@@ -98,24 +96,39 @@ public List<UpdateEntry> get(Catalog catalog) {
}
if (indexedColumns.contains(columnName)) {
- List<String> indexesNames = Arrays.stream(schema.indexes())
- .filter(index -> index.tableId() == table.id())
- .filter(index -> index instanceof
CatalogHashIndexDescriptor
- ? ((CatalogHashIndexDescriptor)
index).columns().contains(columnName)
- : ((CatalogSortedIndexDescriptor)
index).columns().stream().map(CatalogIndexColumnDescriptor::name)
- .anyMatch(column ->
column.equals(columnName))
-
).map(CatalogIndexDescriptor::name).collect(Collectors.toList());
+ List<String> indexesNames = indexesForTable(schema, table)
+ .filter(index ->
indexColumnNames(index).anyMatch(columnName::equals))
+ .map(CatalogIndexDescriptor::name)
+ .collect(Collectors.toList());
throw new CatalogValidationException(format(
"Deleting column '{}' used by index(es) {}, it is not
allowed", columnName, indexesNames));
}
- }
+ });
return List.of(
new DropColumnsEntry(table.id(), columns, schemaName)
);
}
+ private static Stream<CatalogIndexDescriptor>
indexesForTable(CatalogSchemaDescriptor schema, CatalogTableDescriptor table) {
+ return Arrays.stream(schema.indexes())
+ .filter(index -> index.tableId() == table.id() &&
index.status() != CatalogIndexStatus.STOPPING);
Review Comment:
Yes. The idea is that in the code using this method it will be clear that
'we want an alive index' and not that 'we want a not STOPPED index'; the latter
seems to be a little too low-level, the former explains our intention.
--
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]