sashapolo commented on code in PR #3223:
URL: https://github.com/apache/ignite-3/pull/3223#discussion_r1495808627


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/descriptors/CatalogSchemaDescriptor.java:
##########
@@ -78,6 +80,18 @@ public CatalogIndexDescriptor[] indexes() {
         return indexes;
     }
 
+    /**
+     * Returns a list of indexes that have the given name.
+     *
+     * <p>There can be multiple indexes with the same name in a {@link 
CatalogIndexStatus#STOPPING} state, but at most one <em>alive</em>

Review Comment:
   Fixed



##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/DropIndexCommand.java:
##########
@@ -65,7 +65,18 @@ private DropIndexCommand(String schemaName, String 
indexName) throws CatalogVali
     public List<UpdateEntry> get(Catalog catalog) {
         CatalogSchemaDescriptor schema = schemaOrThrow(catalog, schemaName);
 
-        CatalogIndexDescriptor index = indexOrThrow(schema, indexName);
+        List<CatalogIndexDescriptor> indexes = schema.indexes(indexName);

Review Comment:
   Fixed



##########
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) {

Review Comment:
   Fixed



-- 
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]

Reply via email to