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


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -531,6 +539,93 @@ public static CatalogTableDescriptor tableOrThrow(Catalog 
catalog, int tableId)
         return table;
     }
 
+    /**
+     * Returns a descriptor for given zone name or for a default zone from the 
given catalog.
+     *
+     * @param catalog Catalog to check zones' existence.
+     * @param zoneName Zone name to try to find catalog descriptor for. If 
{@code null} then will return default zone descriptor.
+     * @return Returns a descriptor for given zone name if it isn't {@code 
null} or for existed default zone otherwise.
+     * @throws CatalogValidationException In casse if given zone name isn't 
{@code null}, but the given catalog hasn't zone with such name.
+     * @implNote This method assumes, that {@link #shouldCreateNewDefaultZone} 
returns {@code false} with the same input.
+     */
+    public static CatalogZoneDescriptor zoneByNameOrDefaultOrThrow(
+            Catalog catalog,
+            @Nullable String zoneName
+    ) throws CatalogValidationException {
+        if (zoneName != null) {
+            return zoneOrThrow(catalog, zoneName);
+        }
+
+        CatalogZoneDescriptor defaultZone = catalog.defaultZone();
+
+        assert defaultZone != null;

Review Comment:
   I think it's better to make it validation exception. With this assertion we 
assume that default zone should be auto-created if none exists. But this method 
in fact is valid and for the case where it's not true. We just need to hint 
user to specify zone explicitly (or create default zone first)



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