korlov42 commented on code in PR #5121:
URL: https://github.com/apache/ignite-3/pull/5121#discussion_r1933767918


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/AbstractCreateIndexCommand.java:
##########
@@ -83,9 +83,13 @@ public List<UpdateEntry> get(UpdateContext context) {
         Catalog catalog = context.catalog();
         CatalogSchemaDescriptor schema = schemaOrThrow(catalog, schemaName);
 
+        if (ifNotExists && schema.aliveIndex(indexName) != null) {
+            return List.of();
+        }
+
         ensureNoTableIndexOrSysViewExistsWithGivenName(schema, indexName);
 
-        CatalogTableDescriptor table = tableOrThrow(schema, tableName);
+        CatalogTableDescriptor table = tableOrThrow(schema, tableName, 
false).orElseThrow();

Review Comment:
   tbh, this line looks ridiculous now: give me table, or throw exception if 
table doesn't exists (this semantic derived from method's name), but don't 
throw an exception if table doesn't exists (this one derived from 
`shouldThrowIfNotExists=false` parameter), and throw if table doesn't exists 
(call to Optional's `orElseThrow()`). 
   
   We have to stick with only one approach:
   Either add new method `@Nullable CatalogTableDescriptor 
tableOpt(CatalogSchemaDescriptor schema, String name)` and use it wherever 
appropriate
   
   or
   
   change method to `@Nullable CatalogTableDescriptor 
table(CatalogSchemaDescriptor schema, String name, boolean 
shouldThrowIfNotExists)`
   
   or
   
   change method to `Optional<CatalogTableDescriptor> 
table(CatalogSchemaDescriptor schema, String name)`
   
   I don't think any mixture of these may provide decent result
   
   



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