korlov42 commented on code in PR #6712:
URL: https://github.com/apache/ignite-3/pull/6712#discussion_r2439195003
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/storage/NewSchemaEntry.java:
##########
@@ -43,13 +44,17 @@ public CatalogSchemaDescriptor descriptor() {
public Catalog applyUpdate(Catalog catalog, HybridTimestamp timestamp) {
descriptor.updateTimestamp(timestamp);
+ CatalogZoneDescriptor defaultZoneDesc = catalog.defaultZone();
+
return new Catalog(
catalog.version(),
catalog.time(),
catalog.objectIdGenState(),
catalog.zones(),
CollectionUtils.concat(catalog.schemas(), List.of(descriptor)),
- catalog.defaultZone().id()
+ defaultZoneDesc == null
+ ? null
+ : defaultZoneDesc.id()
Review Comment:
```suggestion
defaultZoneIdOpt(catalog)
```
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -542,11 +545,33 @@ public static CatalogTableDescriptor tableOrThrow(Catalog
catalog, int tableId)
*/
public static @Nullable CatalogZoneDescriptor zone(Catalog catalog, String
name, boolean shouldThrowIfNotExists)
throws CatalogValidationException {
+ try {
+ return zone(catalog, name);
+ } catch (CatalogValidationException e) {
+ if (shouldThrowIfNotExists) {
+ throw e;
+ }
+
+ return null;
+ }
+ }
+
+ /**
+ * Returns zone with given name.
+ *
+ * @param catalog Catalog to look up zone in.
+ * @param name Name of the zone of interest.
+ * @return Zone descriptor for given name.
+ * @throws CatalogValidationException If zone with given name is not
exists and flag shouldThrowIfNotExists
+ * set to {@code true}.
+ */
+ public static CatalogZoneDescriptor zone(Catalog catalog, String name)
Review Comment:
```suggestion
public static CatalogZoneDescriptor zoneOrThrow(Catalog catalog, String
name)
```
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -542,11 +545,33 @@ public static CatalogTableDescriptor tableOrThrow(Catalog
catalog, int tableId)
*/
public static @Nullable CatalogZoneDescriptor zone(Catalog catalog, String
name, boolean shouldThrowIfNotExists)
throws CatalogValidationException {
+ try {
+ return zone(catalog, name);
+ } catch (CatalogValidationException e) {
+ if (shouldThrowIfNotExists) {
+ throw e;
+ }
+
+ return null;
+ }
+ }
+
+ /**
+ * Returns zone with given name.
+ *
+ * @param catalog Catalog to look up zone in.
+ * @param name Name of the zone of interest.
+ * @return Zone descriptor for given name.
+ * @throws CatalogValidationException If zone with given name is not
exists and flag shouldThrowIfNotExists
Review Comment:
this method doesn't accept flag
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CreateTableCommand.java:
##########
@@ -127,13 +139,36 @@ public List<UpdateEntry> get(UpdateContext updateContext)
{
ensureNoTableIndexOrSysViewExistsWithGivenName(schema, tableName);
+ int id = catalog.objectIdGenState();
+ int tableId = id++;
+ int pkIndexId = id++;
+
+ // We will have at max 5 entries if there is lazy default data zone
creation action is needed.
+ List<UpdateEntry> updateEntries = new ArrayList<>(5);
+
CatalogZoneDescriptor zone;
if (zoneName == null) {
if (catalog.defaultZone() == null) {
- throw new CatalogValidationException("The zone is not
specified. Please specify zone explicitly or set default one.");
+ int zoneId = id++;
+
+ zone = new CatalogZoneDescriptor(
Review Comment:
we definitely need a test in
`org.apache.ignite.internal.catalog.CatalogTableTest` validation default zone
creation
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -542,11 +545,33 @@ public static CatalogTableDescriptor tableOrThrow(Catalog
catalog, int tableId)
*/
public static @Nullable CatalogZoneDescriptor zone(Catalog catalog, String
name, boolean shouldThrowIfNotExists)
throws CatalogValidationException {
+ try {
+ return zone(catalog, name);
+ } catch (CatalogValidationException e) {
Review Comment:
this is quite peculiar way to reuse code... I would prefer to leave this
method as is and reuse this to implement `zoneOrThrow`
--
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]