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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/SqlSchemaManager.java:
##########
@@ -19,21 +19,29 @@
 
 import java.util.concurrent.CompletableFuture;
 import org.apache.calcite.schema.SchemaPlus;
-import org.jetbrains.annotations.Nullable;
 
 /**
  * Sql schemas operations interface.
  */
 public interface SqlSchemaManager {
     /**
-     * Returns schema with given name and by the given version, if name is not 
specified, returns default schema of the given version.
+     * Returns root schema of the given version.
      */
-    SchemaPlus schema(@Nullable String name, int version);
+    SchemaPlus schema(int version);
 
     /**
-     * Returns schema with given name and by the given timestamp, if name is 
not specified, returns default schema of the given version.
+     * Returns root schema by the given timestamp.
      */
-    SchemaPlus schema(@Nullable String name, long timestamp);
+    SchemaPlus schema(long timestamp);
+
+    /**
+     * Returns table by given id, which version correspond to the one from 
schema of given version.
+     *
+     * @param schemaVersion Version of the schema.
+     * @param tableId A identifier of a table of interest.

Review Comment:
   fixed



##########
modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTestUtilsTest.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.catalog;
+
+import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.await;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasSize;
+
+import java.util.Collection;
+import java.util.List;
+import org.apache.ignite.internal.catalog.commands.ColumnParams;
+import org.apache.ignite.internal.catalog.commands.CreateTableCommand;
+import org.apache.ignite.internal.catalog.commands.CreateTableCommandBuilder;
+import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor;
+import org.apache.ignite.internal.hlc.HybridClockImpl;
+import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
+import org.apache.ignite.sql.ColumnType;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests to verify {@link CatalogTestUtils}.
+ */
+class CatalogTestUtilsTest extends BaseIgniteAbstractTest {
+
+    /**
+     * Simple smoke test to verify test manager is able to process several 
versions of catalog,
+     * and returned instance follows the contract.
+     */
+    @Test
+    void testManagerWorksAsExpected() throws Exception {
+        CatalogManager manager = 
CatalogTestUtils.createCatalogManagerWithTestUpdateLog("test", new 
HybridClockImpl());
+
+        manager.start();
+
+        CreateTableCommandBuilder createTableTemplate = 
CreateTableCommand.builder()
+                .schemaName("PUBLIC")
+                .columns(List.of(
+                        
ColumnParams.builder().name("C1").type(ColumnType.INT32).build(),
+                        
ColumnParams.builder().name("C2").type(ColumnType.INT32).build()
+                ))
+                .primaryKeyColumns(List.of("C1"));
+
+        await(manager.execute(
+                createTableTemplate.tableName("T1").build()
+        ));
+
+        int version1 = manager.latestCatalogVersion();
+
+        await(manager.execute(
+                createTableTemplate.tableName("T2").build()
+        ));
+
+        int version2 = manager.latestCatalogVersion();
+
+        Collection<CatalogTableDescriptor> tablesOfVersion1 = 
manager.tables(version1);
+
+        assertThat(tablesOfVersion1, hasSize(1));
+        assertThat(tablesOfVersion1, hasItem(descriptorWithName("T1")));
+
+        Collection<CatalogTableDescriptor> tablesOfVersion2 = 
manager.tables(version2);
+
+        assertThat(tablesOfVersion2, hasSize(2));
+        assertThat(tablesOfVersion2, hasItem(descriptorWithName("T1")));
+        assertThat(tablesOfVersion2, hasItem(descriptorWithName("T2")));
+
+        manager.stop();
+    }
+
+    private static Matcher<CatalogTableDescriptor> descriptorWithName(String 
name) {
+        return new BaseMatcher<>() {
+            @Override
+            public boolean matches(Object actual) {
+                return actual instanceof CatalogTableDescriptor && 
name.equals(((CatalogTableDescriptor) actual).name());
+            }
+
+            @Override
+            public void describeTo(Description description) {
+                description.appendText(format("should have name '{}'", name));
+            }
+        };
+    }
+}

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