diff --git a/modules/api/src/main/java/org/apache/ignite/compute/BroadcastJobTarget.java b/modules/api/src/main/java/org/apache/ignite/compute/BroadcastJobTarget.java index 181876d136b..11905f5518b 100644 --- a/modules/api/src/main/java/org/apache/ignite/compute/BroadcastJobTarget.java +++ b/modules/api/src/main/java/org/apache/ignite/compute/BroadcastJobTarget.java @@ -21,6 +21,7 @@ import java.util.HashSet; import java.util.Set; import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.table.QualifiedName; /** * Broadcast job execution target. @@ -68,10 +69,23 @@ static BroadcastJobTarget nodes(Set nodes) { * Creates a job target for partitioned execution. For each partition in the provided table the job will be executed on a node that * holds the primary replica. * - * @param tableName Table name. + * @param tableName Name of the table with SQL-parser style quotation, e.g. + * "tbl0" - the table "TBL0" will be looked up, "\"Tbl0\"" - "Tbl0", etc. * @return Job target. */ static BroadcastJobTarget table(String tableName) { - return new TableJobTarget(tableName); + return table(QualifiedName.parse(tableName)); + } + + /** + * Creates a job target for partitioned execution. For each partition in the provided table the job will be executed on a node that + * holds the primary replica. + * + * @param tableName Table name. + * @return Job target. + */ + static BroadcastJobTarget table(QualifiedName tableName) { + // TODO IGNITE-24033 Compute API must use QualifiedName. + return new TableJobTarget(tableName.objectName()); } } diff --git a/modules/api/src/main/java/org/apache/ignite/compute/JobTarget.java b/modules/api/src/main/java/org/apache/ignite/compute/JobTarget.java index 958269430e9..bfefabd2575 100644 --- a/modules/api/src/main/java/org/apache/ignite/compute/JobTarget.java +++ b/modules/api/src/main/java/org/apache/ignite/compute/JobTarget.java @@ -21,6 +21,7 @@ import java.util.HashSet; import java.util.Set; import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.Tuple; import org.apache.ignite.table.mapper.Mapper; @@ -91,7 +92,21 @@ static JobTarget anyNode(Set nodes) { * @return Job target. */ static JobTarget colocated(String tableName, Tuple key) { - return new ColocatedJobTarget(tableName, key, null); + return colocated(QualifiedName.parse(tableName), key); + } + + /** + * Creates a colocated job target for a specific table and key. + * + *

This target determines that a job should be executed on the same node that hosts the data for a given key of provided table. + * + * @param tableName Table name. + * @param key Key. + * @return Job target. + */ + static JobTarget colocated(QualifiedName tableName, Tuple key) { + // TODO IGNITE-24033 Compute API must use QualifiedName. + return new ColocatedJobTarget(tableName.objectName(), key, null); } /** @@ -104,6 +119,20 @@ static JobTarget colocated(String tableName, Tuple key) { * @return Job target. */ static JobTarget colocated(String tableName, K key, Mapper keyMapper) { - return new ColocatedJobTarget(tableName, key, keyMapper); + return colocated(QualifiedName.parse(tableName), key, keyMapper); + } + + /** + * Creates a colocated job target for a specific table and key with mapper. + * + *

This target determines that a job should be executed on the same node that hosts the data for a given key of provided table. + * + * @param tableName Table name. + * @param key Key. + * @return Job target. + */ + static JobTarget colocated(QualifiedName tableName, K key, Mapper keyMapper) { + // TODO IGNITE-24033 Compute API must use QualifiedName. + return new ColocatedJobTarget(tableName.objectName(), key, keyMapper); } } diff --git a/modules/api/src/main/java/org/apache/ignite/lang/TableNotFoundException.java b/modules/api/src/main/java/org/apache/ignite/lang/TableNotFoundException.java index 24763d0c017..e0d8439befb 100644 --- a/modules/api/src/main/java/org/apache/ignite/lang/TableNotFoundException.java +++ b/modules/api/src/main/java/org/apache/ignite/lang/TableNotFoundException.java @@ -18,23 +18,23 @@ package org.apache.ignite.lang; import static org.apache.ignite.lang.ErrorGroups.Table.TABLE_NOT_FOUND_ERR; -import static org.apache.ignite.lang.util.IgniteNameUtils.canonicalName; import java.util.UUID; +import org.apache.ignite.table.QualifiedName; import org.jetbrains.annotations.Nullable; /** * Exception is thrown when a specified table cannot be found. */ public class TableNotFoundException extends IgniteException { + /** * Creates an exception with the given table name. * - * @param schemaName Schema name. * @param tableName Table name. */ - public TableNotFoundException(String schemaName, String tableName) { - super(TABLE_NOT_FOUND_ERR, "The table does not exist [name=" + canonicalName(schemaName, tableName) + ']'); + public TableNotFoundException(QualifiedName tableName) { + super(TABLE_NOT_FOUND_ERR, "The table does not exist [name=" + tableName.toCanonicalForm() + ']'); } /** diff --git a/modules/api/src/main/java/org/apache/ignite/table/IgniteTables.java b/modules/api/src/main/java/org/apache/ignite/table/IgniteTables.java index e7c71aa4ec4..608119961fe 100644 --- a/modules/api/src/main/java/org/apache/ignite/table/IgniteTables.java +++ b/modules/api/src/main/java/org/apache/ignite/table/IgniteTables.java @@ -45,7 +45,17 @@ public interface IgniteTables { * "tbl0" - the table "TBL0" will be looked up, "\"Tbl0\"" - "Tbl0", etc. * @return Table identified by name or {@code null} if table doesn't exist. */ - Table table(String name); + default Table table(String name) { + return table(QualifiedName.parse(name)); + } + + /** + * Gets a table with the specified name if that table exists. + * + * @param name Table name. + * @return Table identified by name or {@code null} if table doesn't exist. + */ + Table table(QualifiedName name); /** * Gets a table with the specified name if that table exists. @@ -54,5 +64,17 @@ public interface IgniteTables { * "tbl0" - the table "TBL0" will be looked up, "\"Tbl0\"" - "Tbl0", etc. * @return Future that represents the pending completion of the operation. */ - CompletableFuture tableAsync(String name); + default CompletableFuture
tableAsync(String name) { + return CompletableFuture.completedFuture(name) + .thenApply(QualifiedName::parse) + .thenCompose(this::tableAsync); + } + + /** + * Gets a table with the specified name if that table exists. + * + * @param name Table name. + * @return Future that represents the pending completion of the operation. + */ + CompletableFuture
tableAsync(QualifiedName name); } diff --git a/modules/api/src/main/java/org/apache/ignite/table/QualifiedName.java b/modules/api/src/main/java/org/apache/ignite/table/QualifiedName.java index 6ab460a0c30..6d57887d11f 100644 --- a/modules/api/src/main/java/org/apache/ignite/table/QualifiedName.java +++ b/modules/api/src/main/java/org/apache/ignite/table/QualifiedName.java @@ -21,6 +21,7 @@ import static org.apache.ignite.lang.util.IgniteNameUtils.identifierStart; import static org.apache.ignite.lang.util.IgniteNameUtils.quote; +import java.io.Serializable; import java.util.NoSuchElementException; import java.util.Objects; import org.jetbrains.annotations.Nullable; @@ -46,7 +47,9 @@ * for quoted names - the unnecessary quotes will be removed preserving escaped double-quote symbols. * E.g. "tbl0" - is equivalent to "TBL0", "\"Tbl0\"" - "Tbl0", etc. */ -public class QualifiedName { +public final class QualifiedName implements Serializable { + private static final long serialVersionUID = -7016402388810709149L; + /** Default schema name. */ public static final String DEFAULT_SCHEMA_NAME = "PUBLIC"; @@ -119,7 +122,7 @@ public static QualifiedName of(@Nullable String schemaName, String objectName) { * @param schemaName Normalized schema name. * @param objectName Normalized object name. */ - private QualifiedName(String schemaName, String objectName) { + QualifiedName(String schemaName, String objectName) { this.schemaIdentifier = schemaName; this.objectIdentifier = objectName; } diff --git a/modules/api/src/main/java/org/apache/ignite/table/Table.java b/modules/api/src/main/java/org/apache/ignite/table/Table.java index 5522fb47348..edf391d486b 100644 --- a/modules/api/src/main/java/org/apache/ignite/table/Table.java +++ b/modules/api/src/main/java/org/apache/ignite/table/Table.java @@ -40,7 +40,7 @@ public interface Table { * * @return Table name. */ - String name(); + QualifiedName name(); /** * Gets the partition manager. diff --git a/modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogApiThreadingTest.java b/modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogApiThreadingTest.java index e712c3dabfa..455c855dfac 100644 --- a/modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogApiThreadingTest.java +++ b/modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogApiThreadingTest.java @@ -22,7 +22,6 @@ import static org.apache.ignite.internal.PublicApiThreadingTests.asyncContinuationPool; import static org.apache.ignite.internal.PublicApiThreadingTests.tryToSwitchFromUserThreadWithDelayedSchemaSync; import static org.apache.ignite.internal.TestDefaultProfilesNames.DEFAULT_AIPERSIST_PROFILE_NAME; -import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl; import static org.apache.ignite.internal.catalog.ItCatalogDslTest.POJO_RECORD_TABLE_NAME; import static org.apache.ignite.internal.catalog.ItCatalogDslTest.ZONE_NAME; import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe; @@ -32,7 +31,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.function.Supplier; -import org.apache.ignite.Ignite; import org.apache.ignite.catalog.IgniteCatalog; import org.apache.ignite.catalog.definitions.TableDefinition; import org.apache.ignite.catalog.definitions.ZoneDefinition; @@ -53,14 +51,8 @@ protected int initialNodes() { @AfterEach void clearDatabase() { - Ignite ignite = CLUSTER.aliveNode(); - - ignite.tables().tables().forEach(table -> sql("DROP TABLE " + table.name())); - - CatalogManagerImpl catalogManager = (CatalogManagerImpl) unwrapIgniteImpl(ignite).catalogManager(); - catalogManager.zones(catalogManager.latestCatalogVersion()).stream() - .filter(zone -> !CatalogManagerImpl.DEFAULT_ZONE_NAME.equals(zone.name())) - .forEach(zone -> sql("DROP ZONE " + zone.name())); + dropAllTables(); + dropAllZonesExceptDefaultOne(); } @ParameterizedTest diff --git a/modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogDslTest.java b/modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogDslTest.java index 7c6d530bfda..9019aceb64e 100644 --- a/modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogDslTest.java +++ b/modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogDslTest.java @@ -405,7 +405,7 @@ public void createAndGetDefinitionTest() { @Test public void createAllColumnTypesFromPojo() { Table table = catalog().createTable(AllColumnTypesPojo.class); - assertEquals("ALLCOLUMNTYPESPOJO", table.name()); + assertEquals("ALLCOLUMNTYPESPOJO", table.name().objectName()); TableDefinition tableDef = catalog().tableDefinition(table.name()); assertEquals(tableDef.tableName(), tableDef.tableName()); diff --git a/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogManagerImpl.java b/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogManagerImpl.java index 7148f4dcc7e..0531a7fab1e 100644 --- a/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogManagerImpl.java +++ b/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogManagerImpl.java @@ -192,8 +192,8 @@ public CompletableFuture stopAsync(ComponentContext componentContext) { } @Override - public @Nullable CatalogTableDescriptor table(String tableName, long timestamp) { - CatalogSchemaDescriptor schema = catalogAt(timestamp).schema(SqlCommon.DEFAULT_SCHEMA_NAME); + public @Nullable CatalogTableDescriptor table(String schemaName, String tableName, long timestamp) { + CatalogSchemaDescriptor schema = catalogAt(timestamp).schema(schemaName); if (schema == null) { return null; } @@ -216,8 +216,8 @@ public Collection tables(int catalogVersion) { } @Override - public @Nullable CatalogIndexDescriptor aliveIndex(String indexName, long timestamp) { - CatalogSchemaDescriptor schema = catalogAt(timestamp).schema(SqlCommon.DEFAULT_SCHEMA_NAME); + public @Nullable CatalogIndexDescriptor aliveIndex(String schemaName, String indexName, long timestamp) { + CatalogSchemaDescriptor schema = catalogAt(timestamp).schema(schemaName); if (schema == null) { return null; } @@ -379,7 +379,7 @@ private CompletableFuture initCatalog(Catalog emptyCatalog) { .dataNodesAutoAdjustScaleDown(INFINITE_TIMER_VALUE) .filter(DEFAULT_FILTER) .storageProfilesParams( - List.of(StorageProfileParams.builder().storageProfile(CatalogService.DEFAULT_STORAGE_PROFILE).build()) + List.of(StorageProfileParams.builder().storageProfile(DEFAULT_STORAGE_PROFILE).build()) ) .build(), AlterZoneSetDefaultCommand.builder() diff --git a/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogService.java b/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogService.java index 4e91a28f041..2934734f601 100644 --- a/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogService.java +++ b/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogService.java @@ -65,24 +65,45 @@ public interface CatalogService extends EventProducer tables(int catalogVersion); /** - * Returns an alive index with the given name, that is an index that has not been dropped yet at a given point in time. + * Returns a descriptor for alive index by the given schema name and index name at given timestamp, + * that is an index that has not been dropped yet at a given point in time. * *

This effectively means that the index must be present in the Catalog and not in the {@link CatalogIndexStatus#STOPPING} * state. */ - @Nullable CatalogIndexDescriptor aliveIndex(String indexName, long timestamp); + @Nullable CatalogIndexDescriptor aliveIndex(String schemaName, String indexName, long timestamp); @Nullable CatalogIndexDescriptor index(int indexId, long timestamp); + /** + * Returns index descriptor by the given index ID and catalog version. + * + * @return Index descriptor or {@code null} if index not found. + */ @Nullable CatalogIndexDescriptor index(int indexId, int catalogVersion); Collection indexes(int catalogVersion); diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogIndexTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogIndexTest.java index b9f112108b9..cdd8f54ae1c 100644 --- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogIndexTest.java +++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogIndexTest.java @@ -78,7 +78,6 @@ import org.apache.ignite.internal.catalog.events.StartBuildingIndexEventParameters; import org.apache.ignite.internal.catalog.events.StoppingIndexEventParameters; import org.apache.ignite.internal.event.EventListener; -import org.apache.ignite.internal.sql.SqlCommon; import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -89,8 +88,6 @@ /** Tests for index related commands. */ public class CatalogIndexTest extends BaseCatalogManagerTest { - private static final String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; - @Test public void testCreateHashIndex() { int tableCreationVersion = await(manager.execute(simpleTable(TABLE_NAME))); @@ -102,7 +99,7 @@ public void testCreateHashIndex() { assertNotNull(schema); assertNull(schema.aliveIndex(INDEX_NAME)); - assertNull(manager.aliveIndex(INDEX_NAME, 123L)); + assertNull(manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, 123L)); // Validate actual catalog schema = manager.schema(indexCreationVersion); @@ -110,7 +107,7 @@ public void testCreateHashIndex() { CatalogHashIndexDescriptor index = (CatalogHashIndexDescriptor) schema.aliveIndex(INDEX_NAME); assertNotNull(schema); - assertSame(index, manager.aliveIndex(INDEX_NAME, clock.nowLong())); + assertSame(index, manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong())); assertSame(index, manager.index(index.id(), clock.nowLong())); // Validate newly created hash index @@ -139,7 +136,7 @@ public void testCreateSortedIndex() { assertNotNull(schema); assertNull(schema.aliveIndex(INDEX_NAME)); - assertNull(manager.aliveIndex(INDEX_NAME, 123L)); + assertNull(manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, 123L)); assertNull(manager.index(4, 123L)); // Validate actual catalog @@ -148,7 +145,7 @@ public void testCreateSortedIndex() { CatalogSortedIndexDescriptor index = (CatalogSortedIndexDescriptor) schema.aliveIndex(INDEX_NAME); assertNotNull(schema); - assertSame(index, manager.aliveIndex(INDEX_NAME, clock.nowLong())); + assertSame(index, manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong())); assertSame(index, manager.index(index.id(), clock.nowLong())); // Validate newly created sorted index @@ -183,10 +180,10 @@ public void testDropTableWithIndex() { assertEquals(SCHEMA_NAME, schema.name()); assertSame(schema, manager.activeSchema(beforeDropTimestamp)); - assertSame(table, manager.table(TABLE_NAME, beforeDropTimestamp)); + assertSame(table, manager.table(SCHEMA_NAME, TABLE_NAME, beforeDropTimestamp)); assertSame(table, manager.table(table.id(), beforeDropTimestamp)); - assertSame(index, manager.aliveIndex(INDEX_NAME, beforeDropTimestamp)); + assertSame(index, manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, beforeDropTimestamp)); assertSame(index, manager.index(index.id(), beforeDropTimestamp)); // Validate actual catalog @@ -197,11 +194,11 @@ public void testDropTableWithIndex() { assertSame(schema, manager.activeSchema(clock.nowLong())); assertNull(schema.table(TABLE_NAME)); - assertNull(manager.table(TABLE_NAME, clock.nowLong())); + assertNull(manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong())); assertNull(manager.table(table.id(), clock.nowLong())); assertThat(schema.aliveIndex(INDEX_NAME), is(nullValue())); - assertThat(manager.aliveIndex(INDEX_NAME, clock.nowLong()), is(nullValue())); + assertThat(manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong()), is(nullValue())); assertThat(manager.index(index.id(), clock.nowLong()), is(nullValue())); } @@ -212,13 +209,14 @@ public void testGetTableIdOnDropIndexEvent() { assertThat(manager.execute(createHashIndexCommand(INDEX_NAME, List.of("VAL"))), willCompleteSuccessfully()); - int indexId = manager.aliveIndex(INDEX_NAME, clock.nowLong()).id(); + + int indexId = manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong()).id(); startBuildingIndex(indexId); makeIndexAvailable(indexId); - int tableId = manager.table(TABLE_NAME, clock.nowLong()).id(); - int pkIndexId = manager.aliveIndex(pkIndexName(TABLE_NAME), clock.nowLong()).id(); + int tableId = manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong()).id(); + int pkIndexId = manager.aliveIndex(SCHEMA_NAME, pkIndexName(TABLE_NAME), clock.nowLong()).id(); assertNotEquals(tableId, indexId); @@ -259,7 +257,7 @@ public void testReCreateIndexWithSameName() { createSomeIndex(TABLE_NAME, INDEX_NAME); int catalogVersion = manager.latestCatalogVersion(); - CatalogIndexDescriptor index1 = manager.aliveIndex(INDEX_NAME, clock.nowLong()); + CatalogIndexDescriptor index1 = manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong()); assertNotNull(index1); int indexId1 = index1.id(); @@ -269,12 +267,12 @@ public void testReCreateIndexWithSameName() { // Drop index. dropIndex(INDEX_NAME); removeIndex(indexId1); - assertNull(manager.aliveIndex(INDEX_NAME, clock.nowLong())); + assertNull(manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong())); // Re-create index with same name. createSomeSortedIndex(TABLE_NAME, INDEX_NAME); - CatalogIndexDescriptor index2 = manager.aliveIndex(INDEX_NAME, clock.nowLong()); + CatalogIndexDescriptor index2 = manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong()); assertNotNull(index2); assertThat(index2.indexType(), equalTo(CatalogIndexDescriptorType.SORTED)); @@ -378,7 +376,7 @@ private void removeIndex(int indexId) { private void dropIndex(String indexName) { assertThat( - manager.execute(DropIndexCommand.builder().indexName(indexName).schemaName(SqlCommon.DEFAULT_SCHEMA_NAME).build()), + manager.execute(DropIndexCommand.builder().indexName(indexName).schemaName(SCHEMA_NAME).build()), willCompleteSuccessfully() ); } @@ -754,7 +752,7 @@ public void testRenameIndex() { long beforeRename = clock.nowLong(); - CatalogIndexDescriptor index = manager.aliveIndex(INDEX_NAME, clock.nowLong()); + CatalogIndexDescriptor index = manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong()); assertThat(index, is(notNullValue())); int indexId = index.id(); @@ -763,22 +761,22 @@ public void testRenameIndex() { renameIndex(INDEX_NAME, INDEX_NAME_2); // Ensure index is available by new name. - assertThat(manager.aliveIndex(INDEX_NAME, clock.nowLong()), is(nullValue())); + assertThat(manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong()), is(nullValue())); - index = manager.aliveIndex(INDEX_NAME_2, clock.nowLong()); + index = manager.aliveIndex(SCHEMA_NAME, INDEX_NAME_2, clock.nowLong()); assertThat(index, is(notNullValue())); assertThat(index.id(), is(indexId)); assertThat(index.name(), is(INDEX_NAME_2)); // Ensure renamed index is available for historical queries. - CatalogIndexDescriptor oldDescriptor = manager.aliveIndex(INDEX_NAME, beforeRename); + CatalogIndexDescriptor oldDescriptor = manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, beforeRename); assertThat(oldDescriptor, is(notNullValue())); assertThat(oldDescriptor.id(), is(indexId)); // Ensure can create new index with same name. createSomeIndex(TABLE_NAME, INDEX_NAME); - index = manager.aliveIndex(INDEX_NAME, clock.nowLong()); + index = manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong()); assertThat(index, is(notNullValue())); assertThat(index.id(), not(indexId)); } @@ -787,23 +785,23 @@ public void testRenameIndex() { public void testRenamePkIndex() { createSomeTable(TABLE_NAME); - CatalogTableDescriptor table = manager.table(TABLE_NAME, clock.nowLong()); + CatalogTableDescriptor table = manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong()); assertThat(table, is(notNullValue())); - assertThat(manager.aliveIndex(INDEX_NAME, clock.nowLong()), is(nullValue())); - assertThat(manager.aliveIndex(pkIndexName(TABLE_NAME), clock.nowLong()), is(notNullValue())); + assertThat(manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong()), is(nullValue())); + assertThat(manager.aliveIndex(SCHEMA_NAME, pkIndexName(TABLE_NAME), clock.nowLong()), is(notNullValue())); int primaryKeyIndexId = table.primaryKeyIndexId(); // Rename index. renameIndex(pkIndexName(TABLE_NAME), INDEX_NAME); - CatalogIndexDescriptor index = manager.aliveIndex(INDEX_NAME, clock.nowLong()); + CatalogIndexDescriptor index = manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong()); assertThat(index, is(notNullValue())); assertThat(index.id(), is(primaryKeyIndexId)); assertThat(index.name(), is(INDEX_NAME)); - assertThat(manager.aliveIndex(pkIndexName(TABLE_NAME), clock.nowLong()), is(nullValue())); + assertThat(manager.aliveIndex(SCHEMA_NAME, pkIndexName(TABLE_NAME), clock.nowLong()), is(nullValue())); } @Test @@ -821,7 +819,7 @@ public void testRenameNonExistingIndex() { } private int indexId(String indexName) { - CatalogIndexDescriptor index = manager.aliveIndex(indexName, clock.nowLong()); + CatalogIndexDescriptor index = manager.aliveIndex(SCHEMA_NAME, indexName, clock.nowLong()); assertNotNull(index, indexName); @@ -833,7 +831,7 @@ private List tableIndexIds(int catalogVersion, int tableId) { } private int tableId(String tableName) { - CatalogTableDescriptor table = manager.table(tableName, clock.nowLong()); + CatalogTableDescriptor table = manager.table(SCHEMA_NAME, tableName, clock.nowLong()); assertNotNull(table, tableName); @@ -849,7 +847,7 @@ private void createSomeIndex(String tableName, String indexName) { private void createSomeSortedIndex(String tableName, String indexName) { CatalogCommand newSortedIndexCommand = createSortedIndexCommand( - SqlCommon.DEFAULT_SCHEMA_NAME, tableName, indexName, false, List.of("key1"), List.of(ASC_NULLS_LAST)); + SCHEMA_NAME, tableName, indexName, false, List.of("key1"), List.of(ASC_NULLS_LAST)); assertThat(manager.execute(newSortedIndexCommand), willCompleteSuccessfully()); } diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerDescriptorCausalityTokenTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerDescriptorCausalityTokenTest.java index 159c910c209..233caa02952 100644 --- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerDescriptorCausalityTokenTest.java +++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerDescriptorCausalityTokenTest.java @@ -52,25 +52,23 @@ import org.apache.ignite.internal.catalog.descriptors.CatalogTableColumnDescriptor; import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor; import org.apache.ignite.internal.catalog.descriptors.CatalogZoneDescriptor; -import org.apache.ignite.internal.sql.SqlCommon; import org.junit.jupiter.api.Test; /** * Test for checking that catalog descriptors entities' "update token" are updated after general catalog operations. */ public class CatalogManagerDescriptorCausalityTokenTest extends BaseCatalogManagerTest { - private static final String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; private static final String ZONE_NAME = "TEST_ZONE_NAME"; private static final String TABLE_NAME_2 = "myTable2"; private static final String NEW_COLUMN_NAME = "NEWCOL"; @Test public void testEmptyCatalog() { - CatalogSchemaDescriptor defaultSchema = manager.schema(SqlCommon.DEFAULT_SCHEMA_NAME, 1); + CatalogSchemaDescriptor defaultSchema = manager.schema(SCHEMA_NAME, 1); assertNotNull(defaultSchema); assertNull(manager.catalog(0).defaultZone()); - assertSame(defaultSchema, manager.activeSchema(SqlCommon.DEFAULT_SCHEMA_NAME, clock.nowLong())); + assertSame(defaultSchema, manager.activeSchema(SCHEMA_NAME, clock.nowLong())); assertSame(defaultSchema, manager.schema(1)); assertSame(defaultSchema, manager.activeSchema(clock.nowLong())); @@ -111,7 +109,7 @@ public void testCreateTable() { assertEquals(1, schema.updateToken()); assertNull(schema.table(TABLE_NAME)); - assertNull(manager.table(TABLE_NAME, 123L)); + assertNull(manager.table(SCHEMA_NAME, TABLE_NAME, 123L)); // Validate actual catalog. schema = manager.schema(SCHEMA_NAME, tableCreationVersion); @@ -121,7 +119,7 @@ public void testCreateTable() { assertEquals(SCHEMA_NAME, schema.name()); assertSame(schema, manager.activeSchema(clock.nowLong())); - assertSame(table, manager.table(TABLE_NAME, clock.nowLong())); + assertSame(table, manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong())); assertSame(table, manager.table(table.id(), clock.nowLong())); // Validate newly created table. @@ -143,10 +141,10 @@ public void testCreateTable() { assertEquals(SCHEMA_NAME, schema.name()); assertSame(schema, manager.activeSchema(clock.nowLong())); - assertSame(table, manager.table(TABLE_NAME, clock.nowLong())); + assertSame(table, manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong())); assertSame(table, manager.table(table.id(), clock.nowLong())); - assertSame(table2, manager.table(TABLE_NAME_2, clock.nowLong())); + assertSame(table2, manager.table(SCHEMA_NAME, TABLE_NAME_2, clock.nowLong())); assertSame(table2, manager.table(table2.id(), clock.nowLong())); assertNotSame(table, table2); @@ -180,10 +178,10 @@ public void testDropTable() { long causalityToken = schema.updateToken(); assertTrue(causalityToken > INITIAL_CAUSALITY_TOKEN); - assertSame(table1, manager.table(TABLE_NAME, beforeDropTimestamp)); + assertSame(table1, manager.table(SCHEMA_NAME, TABLE_NAME, beforeDropTimestamp)); assertSame(table1, manager.table(table1.id(), beforeDropTimestamp)); - assertSame(table2, manager.table(TABLE_NAME_2, beforeDropTimestamp)); + assertSame(table2, manager.table(SCHEMA_NAME, TABLE_NAME_2, beforeDropTimestamp)); assertSame(table2, manager.table(table2.id(), beforeDropTimestamp)); // Validate actual catalog. @@ -194,7 +192,7 @@ public void testDropTable() { assertSame(schema, manager.activeSchema(clock.nowLong())); assertNull(schema.table(TABLE_NAME)); - assertNull(manager.table(TABLE_NAME, clock.nowLong())); + assertNull(manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong())); assertNull(manager.table(table1.id(), clock.nowLong())); // Assert that drop table changes schema's last update token. @@ -285,7 +283,7 @@ public void testCreateHashIndex() { assertNotNull(schema); assertNull(schema.aliveIndex(INDEX_NAME)); - assertNull(manager.aliveIndex(INDEX_NAME, 123L)); + assertNull(manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, 123L)); long schemaCausalityToken = schema.updateToken(); @@ -297,7 +295,7 @@ public void testCreateHashIndex() { CatalogHashIndexDescriptor index = (CatalogHashIndexDescriptor) schema.aliveIndex(INDEX_NAME); assertNotNull(schema); - assertSame(index, manager.aliveIndex(INDEX_NAME, clock.nowLong())); + assertSame(index, manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong())); assertSame(index, manager.index(index.id(), clock.nowLong())); assertTrue(schema.updateToken() > schemaCausalityToken); @@ -325,7 +323,7 @@ public void testCreateSortedIndex() { assertNotNull(schema); assertNull(schema.aliveIndex(INDEX_NAME)); - assertNull(manager.aliveIndex(INDEX_NAME, 123L)); + assertNull(manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, 123L)); long schemaCausalityToken = schema.updateToken(); assertTrue(schemaCausalityToken > INITIAL_CAUSALITY_TOKEN); @@ -336,7 +334,7 @@ public void testCreateSortedIndex() { CatalogSortedIndexDescriptor index = (CatalogSortedIndexDescriptor) schema.aliveIndex(INDEX_NAME); assertNotNull(schema); - assertSame(index, manager.aliveIndex(INDEX_NAME, clock.nowLong())); + assertSame(index, manager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong())); assertSame(index, manager.index(index.id(), clock.nowLong())); assertTrue(schema.updateToken() > schemaCausalityToken); diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerSelfTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerSelfTest.java index ce2d7552c25..db2138d665a 100644 --- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerSelfTest.java +++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerSelfTest.java @@ -69,7 +69,6 @@ import org.apache.ignite.internal.hlc.HybridTimestamp; import org.apache.ignite.internal.lang.IgniteInternalException; import org.apache.ignite.internal.manager.ComponentContext; -import org.apache.ignite.internal.sql.SqlCommon; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -77,7 +76,6 @@ * Catalog manager self test. */ public class CatalogManagerSelfTest extends BaseCatalogManagerTest { - private static final String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; @Test public void testEmptyCatalog() { diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTableTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTableTest.java index daf448c3f3c..bf9e361e3b5 100644 --- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTableTest.java +++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTableTest.java @@ -96,7 +96,6 @@ import org.apache.ignite.internal.catalog.events.DropTableEventParameters; import org.apache.ignite.internal.catalog.events.RenameTableEventParameters; import org.apache.ignite.internal.event.EventListener; -import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.sql.ColumnType; import org.hamcrest.TypeSafeMatcher; import org.jetbrains.annotations.Nullable; @@ -108,7 +107,6 @@ /** Tests for table related commands. */ public class CatalogTableTest extends BaseCatalogManagerTest { - private static final String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; private static final String NEW_COLUMN_NAME = "NEWCOL"; private static final String NEW_COLUMN_NAME_2 = "NEWCOL2"; private static final int DFLT_TEST_PRECISION = 11; @@ -135,8 +133,8 @@ public void testCreateTable() { assertSame(schema, manager.activeSchema(timePriorToTableCreation)); assertNull(schema.table(TABLE_NAME)); - assertNull(manager.table(TABLE_NAME, 123L)); - assertNull(manager.aliveIndex(pkIndexName(TABLE_NAME), 123L)); + assertNull(manager.table(SCHEMA_NAME, TABLE_NAME, 123L)); + assertNull(manager.aliveIndex(SCHEMA_NAME, pkIndexName(TABLE_NAME), 123L)); // Validate actual catalog schema = manager.schema(SCHEMA_NAME, tableCreationVersion); @@ -147,10 +145,10 @@ public void testCreateTable() { assertEquals(SCHEMA_NAME, schema.name()); assertSame(schema, manager.activeSchema(clock.nowLong())); - assertSame(table, manager.table(TABLE_NAME, clock.nowLong())); + assertSame(table, manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong())); assertSame(table, manager.table(table.id(), clock.nowLong())); - assertSame(pkIndex, manager.aliveIndex(pkIndexName(TABLE_NAME), clock.nowLong())); + assertSame(pkIndex, manager.aliveIndex(SCHEMA_NAME, pkIndexName(TABLE_NAME), clock.nowLong())); assertSame(pkIndex, manager.index(pkIndex.id(), clock.nowLong())); // Validate newly created table @@ -243,10 +241,10 @@ public void testDropTable() { assertEquals(SCHEMA_NAME, schema.name()); assertSame(schema, manager.activeSchema(beforeDropTimestamp)); - assertSame(table1, manager.table(TABLE_NAME, beforeDropTimestamp)); + assertSame(table1, manager.table(SCHEMA_NAME, TABLE_NAME, beforeDropTimestamp)); assertSame(table1, manager.table(table1.id(), beforeDropTimestamp)); - assertSame(pkIndex1, manager.aliveIndex(pkIndexName(TABLE_NAME), beforeDropTimestamp)); + assertSame(pkIndex1, manager.aliveIndex(SCHEMA_NAME, pkIndexName(TABLE_NAME), beforeDropTimestamp)); assertSame(pkIndex1, manager.index(pkIndex1.id(), beforeDropTimestamp)); // Validate actual catalog @@ -257,11 +255,11 @@ public void testDropTable() { assertSame(schema, manager.activeSchema(clock.nowLong())); assertNull(schema.table(TABLE_NAME)); - assertNull(manager.table(TABLE_NAME, clock.nowLong())); + assertNull(manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong())); assertNull(manager.table(table1.id(), clock.nowLong())); assertThat(schema.aliveIndex(pkIndexName(TABLE_NAME)), is(nullValue())); - assertThat(manager.aliveIndex(pkIndexName(TABLE_NAME), clock.nowLong()), is(nullValue())); + assertThat(manager.aliveIndex(SCHEMA_NAME, pkIndexName(TABLE_NAME), clock.nowLong()), is(nullValue())); assertThat(manager.index(pkIndex1.id(), clock.nowLong()), is(nullValue())); } @@ -270,17 +268,17 @@ public void testReCreateTableWithSameName() { assertThat(manager.execute(simpleTable(TABLE_NAME)), willCompleteSuccessfully()); int catalogVersion = manager.latestCatalogVersion(); - CatalogTableDescriptor table1 = manager.table(TABLE_NAME, clock.nowLong()); + CatalogTableDescriptor table1 = manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong()); assertNotNull(table1); // Drop table. assertThat(manager.execute(dropTableCommand(TABLE_NAME)), willCompleteSuccessfully()); - assertNull(manager.table(TABLE_NAME, clock.nowLong())); + assertNull(manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong())); // Re-create table with same name. assertThat(manager.execute(simpleTable(TABLE_NAME)), willCompleteSuccessfully()); - CatalogTableDescriptor table2 = manager.table(TABLE_NAME, clock.nowLong()); + CatalogTableDescriptor table2 = manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong()); assertNotNull(table2); // Ensure these are different tables. @@ -554,7 +552,7 @@ public void addColumnIncrementsTableVersion() { assertThat(manager.execute(addColumnParams(TABLE_NAME, columnParams("val2", INT32))), willCompleteSuccessfully()); - CatalogTableDescriptor table = manager.table(TABLE_NAME, Long.MAX_VALUE); + CatalogTableDescriptor table = manager.table(SCHEMA_NAME, TABLE_NAME, Long.MAX_VALUE); assertThat(table.tableVersion(), is(2)); } @@ -563,7 +561,7 @@ public void addColumnIncrementsTableVersion() { public void createTableProducesTableVersion1() { createSomeTable(TABLE_NAME); - CatalogTableDescriptor table = manager.table(TABLE_NAME, Long.MAX_VALUE); + CatalogTableDescriptor table = manager.table(SCHEMA_NAME, TABLE_NAME, Long.MAX_VALUE); assertThat(table.tableVersion(), is(1)); } @@ -574,7 +572,7 @@ public void dropColumnIncrementsTableVersion() { assertThat(manager.execute(dropColumnParams(TABLE_NAME, "val1")), willCompleteSuccessfully()); - CatalogTableDescriptor table = manager.table(TABLE_NAME, Long.MAX_VALUE); + CatalogTableDescriptor table = manager.table(SCHEMA_NAME, TABLE_NAME, Long.MAX_VALUE); assertThat(table.tableVersion(), is(2)); } @@ -644,7 +642,7 @@ public void testGetCatalogEntityInCatalogEvent() { public void testGetTableByIdAndCatalogVersion() { int tableCreationVersion = await(manager.execute(simpleTable(TABLE_NAME))); - CatalogTableDescriptor table = manager.table(TABLE_NAME, clock.nowLong()); + CatalogTableDescriptor table = manager.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong()); assertNull(manager.table(table.id(), tableCreationVersion - 1)); assertSame(table, manager.table(table.id(), tableCreationVersion)); @@ -664,7 +662,7 @@ public void alterColumnIncrementsTableVersion() { ); assertThat(future, willCompleteSuccessfully()); - CatalogTableDescriptor table = manager.table(TABLE_NAME, Long.MAX_VALUE); + CatalogTableDescriptor table = manager.table(SCHEMA_NAME, TABLE_NAME, Long.MAX_VALUE); assertThat(table.tableVersion(), is(2)); } diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogZoneTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogZoneTest.java index ebf80a0fff5..6f55c9be7d5 100644 --- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogZoneTest.java +++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogZoneTest.java @@ -144,7 +144,7 @@ public void testSetDefaultZone() { assertThat(manager.execute(simpleTable(TABLE_NAME)), willCompleteSuccessfully()); Catalog catalog = latestActiveCatalog(); - CatalogTableDescriptor tab = Objects.requireNonNull(manager.table(TABLE_NAME, catalog.time())); + CatalogTableDescriptor tab = Objects.requireNonNull(manager.table(SCHEMA_NAME, TABLE_NAME, catalog.time())); assertEquals(catalog.defaultZone().id(), tab.zoneId()); } diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/commands/CatalogUtilsTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/commands/CatalogUtilsTest.java index 15d943cb20e..711cee9df85 100644 --- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/commands/CatalogUtilsTest.java +++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/commands/CatalogUtilsTest.java @@ -56,6 +56,8 @@ /** For {@link CatalogUtils} testing. */ public class CatalogUtilsTest extends BaseIgniteAbstractTest { + private static final String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; + private static final String TABLE_NAME = "test_table"; private static final String COLUMN_NAME = "key"; @@ -81,11 +83,11 @@ void testReplaceTable() { createTable("foo"); createTable("bar"); - CatalogSchemaDescriptor schema = catalogManager.activeSchema(SqlCommon.DEFAULT_SCHEMA_NAME, clock.nowLong()); + CatalogSchemaDescriptor schema = catalogManager.activeSchema(SCHEMA_NAME, clock.nowLong()); assertThat(schema, is(notNullValue())); - CatalogTableDescriptor fooTable = catalogManager.table("foo", clock.nowLong()); + CatalogTableDescriptor fooTable = catalogManager.table(SCHEMA_NAME, "foo", clock.nowLong()); assertThat(fooTable, is(notNullValue())); @@ -106,7 +108,7 @@ void testReplaceTable() { @Test void testReplaceTableMissingTable() { - CatalogSchemaDescriptor schema = catalogManager.activeSchema(SqlCommon.DEFAULT_SCHEMA_NAME, clock.nowLong()); + CatalogSchemaDescriptor schema = catalogManager.activeSchema(SCHEMA_NAME, clock.nowLong()); assertThat(schema, is(notNullValue())); @@ -127,11 +129,11 @@ void testReplaceIndex() { createIndex(tableName, "foo"); createIndex(tableName, "bar"); - CatalogSchemaDescriptor schema = catalogManager.activeSchema(SqlCommon.DEFAULT_SCHEMA_NAME, clock.nowLong()); + CatalogSchemaDescriptor schema = catalogManager.activeSchema(SCHEMA_NAME, clock.nowLong()); assertThat(schema, is(notNullValue())); - var fooIndex = (CatalogHashIndexDescriptor) catalogManager.aliveIndex("foo", clock.nowLong()); + var fooIndex = (CatalogHashIndexDescriptor) catalogManager.aliveIndex(SCHEMA_NAME, "foo", clock.nowLong()); assertThat(fooIndex, is(notNullValue())); @@ -154,7 +156,7 @@ void testReplaceIndex() { @Test void testReplaceIndexMissingIndex() { - CatalogSchemaDescriptor schema = catalogManager.activeSchema(SqlCommon.DEFAULT_SCHEMA_NAME, clock.nowLong()); + CatalogSchemaDescriptor schema = catalogManager.activeSchema(SCHEMA_NAME, clock.nowLong()); assertThat(schema, is(notNullValue())); @@ -182,7 +184,7 @@ void testClusterWideEnsuredActivationTimestamp() { private void createTable(String tableName) { CatalogCommand catalogCommand = CreateTableCommand.builder() - .schemaName(SqlCommon.DEFAULT_SCHEMA_NAME) + .schemaName(SCHEMA_NAME) .tableName(tableName) .columns(List.of(ColumnParams.builder().name(COLUMN_NAME).type(INT32).build())) // Any type of a primary key index can be used. @@ -198,7 +200,7 @@ private void createTable(String tableName) { private int createIndex(String tableName, String indexName) { CatalogCommand catalogCommand = CreateHashIndexCommand.builder() - .schemaName(SqlCommon.DEFAULT_SCHEMA_NAME) + .schemaName(SCHEMA_NAME) .tableName(tableName) .indexName(indexName) .columns(List.of(COLUMN_NAME)) @@ -207,6 +209,6 @@ private int createIndex(String tableName, String indexName) { assertThat(catalogManager.execute(catalogCommand), willCompleteSuccessfully()); - return catalogManager.aliveIndex(indexName, clock.nowLong()).id(); + return catalogManager.aliveIndex(SCHEMA_NAME, indexName, clock.nowLong()).id(); } } diff --git a/modules/catalog/src/testFixtures/java/org/apache/ignite/internal/catalog/BaseCatalogManagerTest.java b/modules/catalog/src/testFixtures/java/org/apache/ignite/internal/catalog/BaseCatalogManagerTest.java index 1447a96f27f..244bfae6ae9 100644 --- a/modules/catalog/src/testFixtures/java/org/apache/ignite/internal/catalog/BaseCatalogManagerTest.java +++ b/modules/catalog/src/testFixtures/java/org/apache/ignite/internal/catalog/BaseCatalogManagerTest.java @@ -78,6 +78,8 @@ public abstract class BaseCatalogManagerTest extends BaseIgniteAbstractTest { private static final String NODE_NAME = "test"; + protected static final String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; + protected static final String TABLE_NAME = "test_table"; protected static final String TABLE_NAME_2 = "test_table_2"; protected static final String TABLE_NAME_3 = "test_table_3"; diff --git a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/reset/ItResetPartitionsTest.java b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/reset/ItResetPartitionsTest.java index 5b32901391b..9156d035b55 100644 --- a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/reset/ItResetPartitionsTest.java +++ b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/reset/ItResetPartitionsTest.java @@ -80,13 +80,13 @@ public void testResetPartitionZoneNotFound() { @Test public void testResetPartitionTableNotFound() { - String unknownTable = canonicalName("PUBLIC", "unknown_table"); + String unknownTable ="PUBLIC.unknown_table"; execute(CLUSTER_URL_OPTION, NODE_URL, RECOVERY_TABLE_NAME_OPTION, unknownTable, RECOVERY_ZONE_NAME_OPTION, ZONE); - assertErrOutputContains("The table does not exist [name=" + unknownTable + "]"); + assertErrOutputContains("The table does not exist [name=" + unknownTable.toUpperCase() + "]"); assertOutputIsEmpty(); } diff --git a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/restart/ItRestartPartitionsTest.java b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/restart/ItRestartPartitionsTest.java index 2197186c9e2..84cc4bb741d 100644 --- a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/restart/ItRestartPartitionsTest.java +++ b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/restart/ItRestartPartitionsTest.java @@ -104,7 +104,7 @@ public void testRestartPartitionZoneNotFound() { @Test public void testRestartPartitionTableNotFound() { - String unknownTable = canonicalName("PUBLIC", "unknown_table"); + String unknownTable = "PUBLIC.unknown_table"; execute(CLUSTER_URL_OPTION, NODE_URL, RECOVERY_TABLE_NAME_OPTION, unknownTable, @@ -112,7 +112,7 @@ public void testRestartPartitionTableNotFound() { ); assertOutputIsEmpty(); - assertErrOutputContains("The table does not exist [name=" + unknownTable + "]"); + assertErrOutputContains("The table does not exist [name=" + unknownTable.toUpperCase() + "]"); } @Test diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableGetRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableGetRequest.java index 11b05f13002..ecb37eb12f8 100644 --- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableGetRequest.java +++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableGetRequest.java @@ -48,7 +48,7 @@ public static CompletableFuture process( out.packNil(); } else { out.packInt(((TableViewInternal) table).tableId()); - out.packString(quoteTableNameIfNotAllUpper(table.name())); + out.packString(quoteTableNameIfNotAllUpper(table.name().objectName())); } }); } diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTablesGetRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTablesGetRequest.java index 174255c3363..1be6db35e37 100644 --- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTablesGetRequest.java +++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTablesGetRequest.java @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture; import org.apache.ignite.internal.client.proto.ClientMessagePacker; import org.apache.ignite.internal.table.TableViewInternal; +import org.apache.ignite.lang.util.IgniteNameUtils; import org.apache.ignite.table.IgniteTables; /** @@ -44,8 +45,25 @@ public static CompletableFuture process( var tableImpl = (TableViewInternal) table; out.packInt(tableImpl.tableId()); - out.packString(table.name()); + out.packString(quoteTableNameIfNotAllUpper(table.name().objectName())); } }); } + + private static String quoteTableNameIfNotAllUpper(String name) { + // TODO: IGNITE-24029 use QualifiedName. + for (int i = 0; i < name.length(); i++) { + char ch = name.charAt(i); + + if (Character.isDigit(ch) || ch == '_') { + continue; + } + + if (!Character.isUpperCase(ch)) { + return IgniteNameUtils.quote(name); + } + } + + return name; + } } diff --git a/modules/client-handler/src/testFixtures/java/org/apache/ignite/client/handler/FakeCatalogService.java b/modules/client-handler/src/testFixtures/java/org/apache/ignite/client/handler/FakeCatalogService.java index 03182e0ce22..e34348b85e1 100644 --- a/modules/client-handler/src/testFixtures/java/org/apache/ignite/client/handler/FakeCatalogService.java +++ b/modules/client-handler/src/testFixtures/java/org/apache/ignite/client/handler/FakeCatalogService.java @@ -52,7 +52,7 @@ public Catalog catalog(int catalogVersion) { } @Override - public CatalogTableDescriptor table(String tableName, long timestamp) { + public CatalogTableDescriptor table(String schemaName, String tableName, long timestamp) { return null; } @@ -73,7 +73,7 @@ public Collection tables(int catalogVersion) { } @Override - public CatalogIndexDescriptor aliveIndex(String indexName, long timestamp) { + public CatalogIndexDescriptor aliveIndex(String schemaName, String indexName, long timestamp) { return null; } diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/compute/ClientCompute.java b/modules/client/src/main/java/org/apache/ignite/internal/client/compute/ClientCompute.java index 8f4b37fd6a7..445ba3485f0 100644 --- a/modules/client/src/main/java/org/apache/ignite/internal/client/compute/ClientCompute.java +++ b/modules/client/src/main/java/org/apache/ignite/internal/client/compute/ClientCompute.java @@ -74,6 +74,8 @@ import org.apache.ignite.lang.IgniteException; import org.apache.ignite.lang.TableNotFoundException; import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.table.QualifiedName; +import org.apache.ignite.table.QualifiedNameHelper; import org.apache.ignite.table.Tuple; import org.apache.ignite.table.mapper.Mapper; import org.apache.ignite.table.partition.Partition; @@ -90,7 +92,7 @@ public class ClientCompute implements IgniteCompute { private final ClientTables tables; /** Cached tables. */ - private final ConcurrentHashMap tableCache = new ConcurrentHashMap<>(); + private final ConcurrentHashMap tableCache = new ConcurrentHashMap<>(); /** * Constructor. @@ -448,17 +450,19 @@ private static CompletableFuture executePartitioned( ); } + // TODO IGNITE-24033 Compute API should use QualifiedName. private CompletableFuture getTable(String tableName) { // Cache tables by name to avoid extra network call on every executeColocated. - var cached = tableCache.get(tableName); + QualifiedName qualifiedName = QualifiedNameHelper.fromNormalized(SqlCommon.DEFAULT_SCHEMA_NAME, tableName); + var cached = tableCache.get(qualifiedName); if (cached != null) { return completedFuture(cached); } - return tables.tableAsync(tableName).thenApply(t -> { + return tables.tableAsync(qualifiedName).thenApply(t -> { if (t == null) { - throw new TableNotFoundException(SqlCommon.DEFAULT_SCHEMA_NAME, tableName); + throw new TableNotFoundException(qualifiedName); } ClientTable clientTable = (ClientTable) t; @@ -483,7 +487,9 @@ private CompletableFuture handleMissingTable( if (clientEx.code() == TABLE_ID_NOT_FOUND_ERR) { // Table was dropped - remove from cache. - tableCache.remove(tableName); + // TODO IGNITE-24033 Make Client API use QualifiedName. + QualifiedName qualifiedName = QualifiedNameHelper.fromNormalized(SqlCommon.DEFAULT_SCHEMA_NAME, tableName); + tableCache.remove(qualifiedName); return retry.get(); } diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/AbstractClientView.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/AbstractClientView.java index e5722e21c5e..46c2f8197ca 100644 --- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/AbstractClientView.java +++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/AbstractClientView.java @@ -17,14 +17,11 @@ package org.apache.ignite.internal.client.table; -import static java.util.stream.Collectors.toSet; import static org.apache.ignite.internal.table.criteria.CriteriaExceptionMapperUtil.mapToPublicCriteriaException; import static org.apache.ignite.internal.util.ExceptionUtils.unwrapCause; import static org.apache.ignite.internal.util.ViewUtils.sync; -import static org.apache.ignite.lang.util.IgniteNameUtils.parseSimpleName; import java.util.Arrays; -import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.function.Function; @@ -38,6 +35,7 @@ import org.apache.ignite.sql.ResultSetMetadata; import org.apache.ignite.sql.SqlRow; import org.apache.ignite.sql.Statement; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.criteria.Criteria; import org.apache.ignite.table.criteria.CriteriaQueryOptions; import org.apache.ignite.table.criteria.CriteriaQuerySource; @@ -82,26 +80,6 @@ protected static String[] columnNames(ClientColumn[] columns) { return columnNames; } - /** - * Construct SQL query and arguments for prepare statement. - * - * @param tableName Table name. - * @param columns Table columns. - * @param criteria The predicate to filter entries or {@code null} to return all entries from the underlying table. - * @return SQL query and it's arguments. - */ - protected static SqlSerializer createSqlSerializer(String tableName, ClientColumn[] columns, @Nullable Criteria criteria) { - Set columnNames = Arrays.stream(columns) - .map(ClientColumn::name) - .collect(toSet()); - - return new SqlSerializer.Builder() - .tableName(parseSimpleName(tableName)) - .columns(columnNames) - .where(criteria) - .build(); - } - /** * Create conversion function for objects contained by result set to criteria query objects. * @@ -117,7 +95,7 @@ protected static SqlSerializer createSqlSerializer(String tableName, ClientColum @Override public Cursor query(@Nullable Transaction tx, @Nullable Criteria criteria, @Nullable String indexName, @Nullable CriteriaQueryOptions opts) { - return new CursorAdapter<>(sync(queryAsync(tx, criteria, null, opts))); + return new CursorAdapter<>(sync(queryAsync(tx, criteria, indexName, opts))); } /** {@inheritDoc} */ @@ -132,7 +110,12 @@ public CompletableFuture> queryAsync( return tbl.getLatestSchema() .thenCompose((schema) -> { - SqlSerializer ser = createSqlSerializer(tbl.name(), schema.columns(), criteria); + SqlSerializer ser = new SqlSerializer.Builder() + .columns(Arrays.asList(columnNames(schema.columns()))) + .tableName(tbl.name()) + .indexName(indexName != null ? QualifiedName.parse(indexName).objectName() : null) + .where(criteria) + .build(); Statement statement = new StatementBuilderImpl().query(ser.toString()).pageSize(opts0.pageSize()).build(); diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java index f2e06421f23..0b7464e8d84 100644 --- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java +++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java @@ -52,6 +52,7 @@ import org.apache.ignite.internal.tostring.IgniteToStringBuilder; import org.apache.ignite.lang.IgniteException; import org.apache.ignite.table.KeyValueView; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.RecordView; import org.apache.ignite.table.Table; import org.apache.ignite.table.Tuple; @@ -68,7 +69,7 @@ public class ClientTable implements Table { private final int id; // TODO: table name can change, this approach should probably be reworked, see https://issues.apache.org/jira/browse/IGNITE-21237. - private final String name; + private final QualifiedName name; private final ReliableChannel ch; @@ -106,11 +107,11 @@ public ClientTable( ReliableChannel ch, MarshallersProvider marshallers, int id, - String name + QualifiedName name ) { assert ch != null; assert marshallers != null; - assert name != null && !name.isEmpty(); + assert name != null; this.ch = ch; this.marshallers = marshallers; @@ -141,7 +142,7 @@ ReliableChannel channel() { /** {@inheritDoc} */ @Override - public String name() { + public QualifiedName name() { return name; } @@ -639,8 +640,10 @@ synchronized CompletableFuture> getPartitionAssignment() { if (oldPartitionCount < 0) { partitionCount = cnt; } else if (oldPartitionCount != cnt) { - throw new IgniteException(INTERNAL_ERR, - String.format("Partition count has changed for table '%s': %d -> %d", name, oldPartitionCount, cnt)); + String message = String.format("Partition count has changed for table '%s': %d -> %d", + name.toCanonicalForm(), oldPartitionCount, cnt); + + throw new IgniteException(INTERNAL_ERR, message); } boolean assignmentAvailable = r.in().unpackBoolean(); diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java index baf128afbb6..3f361673423 100644 --- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java +++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java @@ -27,6 +27,7 @@ import org.apache.ignite.internal.client.proto.ClientOp; import org.apache.ignite.internal.marshaller.MarshallersProvider; import org.apache.ignite.table.IgniteTables; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.Table; /** @@ -63,7 +64,10 @@ public CompletableFuture> tablesAsync() { var res = new ArrayList

(cnt); for (int i = 0; i < cnt; i++) { - res.add(new ClientTable(ch, marshallers, in.unpackInt(), in.unpackString())); + int tableId = in.unpackInt(); + QualifiedName name = QualifiedName.parse(in.unpackString()); + + res.add(new ClientTable(ch, marshallers, tableId, name)); } return res; @@ -72,18 +76,18 @@ public CompletableFuture> tablesAsync() { /** {@inheritDoc} */ @Override - public Table table(String name) { + public Table table(QualifiedName name) { return sync(tableAsync(name)); } /** {@inheritDoc} */ @Override - public CompletableFuture
tableAsync(String name) { + public CompletableFuture
tableAsync(QualifiedName name) { Objects.requireNonNull(name); - return ch.serviceAsync(ClientOp.TABLE_GET, w -> w.out().packString(name), + return ch.serviceAsync(ClientOp.TABLE_GET, w -> w.out().packString(name.toCanonicalForm()), r -> r.in().tryUnpackNil() ? null - : new ClientTable(ch, marshallers, r.in().unpackInt(), r.in().unpackString())); + : new ClientTable(ch, marshallers, r.in().unpackInt(), QualifiedName.parse(r.in().unpackString()))); } } diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java index c0908449bfc..30fe7263434 100644 --- a/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java +++ b/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java @@ -64,6 +64,7 @@ import org.apache.ignite.internal.testframework.IgniteTestUtils; import org.apache.ignite.lang.IgniteException; import org.apache.ignite.lang.TableNotFoundException; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.Tuple; import org.apache.ignite.table.mapper.Mapper; import org.junit.jupiter.api.AfterEach; @@ -196,10 +197,10 @@ public void testExecuteColocatedThrowsTableNotFoundExceptionWhenTableDoesNotExis var ex = assertThrows(CompletionException.class, () -> client.compute().executeAsync( - JobTarget.colocated("bad-tbl", key), JobDescriptor.builder("job").build(), null).join()); + JobTarget.colocated("\"bad-tbl\"", key), JobDescriptor.builder("job").build(), null).join()); var tblNotFoundEx = (TableNotFoundException) ex.getCause(); - assertThat(tblNotFoundEx.getMessage(), containsString("The table does not exist [name=\"PUBLIC\".\"bad-tbl\"]")); + assertThat(tblNotFoundEx.getMessage(), containsString("The table does not exist [name=PUBLIC.\"bad-tbl\"]")); assertEquals(TABLE_NOT_FOUND_ERR, tblNotFoundEx.code()); } } @@ -224,8 +225,8 @@ void testExecuteColocatedUpdatesTableCacheOnTableDrop(boolean forceLoadAssignmen createTable(tableName); if (forceLoadAssignment) { - Map tables = IgniteTestUtils.getFieldValue(client.compute(), "tableCache"); - ClientTable table = tables.get(tableName); + Map tables = IgniteTestUtils.getFieldValue(client.compute(), "tableCache"); + ClientTable table = tables.get(QualifiedName.fromSimple(tableName)); assertNotNull(table); IgniteTestUtils.setFieldValue(table, "partitionAssignment", null); } diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientLoggingTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientLoggingTest.java index bcd4f1f8c45..fcfe64e12f0 100644 --- a/modules/client/src/test/java/org/apache/ignite/client/ClientLoggingTest.java +++ b/modules/client/src/test/java/org/apache/ignite/client/ClientLoggingTest.java @@ -61,8 +61,8 @@ public void loggersSetToDifferentClientsNotInterfereWithEachOther() { var client1 = createClient(loggerFactory1, 10901, 10902); var client2 = createClient(loggerFactory2, 10901, 10902); - assertEquals("t", client1.tables().tables().get(0).name()); - assertEquals("t", client2.tables().tables().get(0).name()); + assertEquals("T", client1.tables().tables().get(0).name().objectName()); + assertEquals("T", client2.tables().tables().get(0).name().objectName()); server.close(); @@ -71,8 +71,8 @@ public void loggersSetToDifferentClientsNotInterfereWithEachOther() { server2 = startServer(ignite2, 10902); - assertEquals("t2", client1.tables().tables().get(0).name()); - assertEquals("t2", client2.tables().tables().get(0).name()); + assertEquals("T2", client1.tables().tables().get(0).name().objectName()); + assertEquals("T2", client2.tables().tables().get(0).name().objectName()); assertThat(loggerFactory1.logger.entries(), not(empty())); assertThat(loggerFactory2.logger.entries(), not(empty())); diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java index ca97cb0dad8..271d5358c39 100644 --- a/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java +++ b/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java @@ -466,9 +466,9 @@ public void testColumnTypeMismatchThrowsException() { @Test public void testGetFromDroppedTableThrowsException() { - ((FakeIgniteTables) server.tables()).createTable("drop-me"); - Table clientTable = client.tables().table("drop-me"); - ((FakeIgniteTables) server.tables()).dropTable("drop-me"); + ((FakeIgniteTables) server.tables()).createTable("\"drop-me\""); + Table clientTable = client.tables().table("\"drop-me\""); + ((FakeIgniteTables) server.tables()).dropTable("\"drop-me\""); Tuple tuple = Tuple.create().set("id", 1); var ex = assertThrows(IgniteException.class, () -> clientTable.recordView().get(null, tuple)); diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientTablesTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientTablesTest.java index ee03b57143e..67511de0eca 100644 --- a/modules/client/src/test/java/org/apache/ignite/client/ClientTablesTest.java +++ b/modules/client/src/test/java/org/apache/ignite/client/ClientTablesTest.java @@ -17,10 +17,12 @@ package org.apache.ignite.client; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import java.util.Comparator; +import java.util.stream.Collectors; import org.apache.ignite.client.fakes.FakeIgniteTables; import org.apache.ignite.table.Table; import org.junit.jupiter.api.Test; @@ -37,9 +39,7 @@ public void testTablesWhenTablesExist() { var tables = client.tables().tables(); assertEquals(2, tables.size()); - tables.sort(Comparator.comparing(Table::name)); - assertEquals(DEFAULT_TABLE, tables.get(0).name()); - assertEquals("t", tables.get(1).name()); + assertThat(tables.stream().map(t -> t.name().objectName()).collect(Collectors.toList()), containsInAnyOrder(DEFAULT_TABLE, "T")); } @Test @@ -54,12 +54,12 @@ public void testTableReturnsInstanceWhenExists() { ((FakeIgniteTables) server.tables()).createTable(DEFAULT_TABLE); Table table = client.tables().table(DEFAULT_TABLE); - assertEquals(DEFAULT_TABLE, table.name()); + assertEquals(DEFAULT_TABLE, table.name().objectName()); } @Test public void testTableReturnsNullWhenDoesNotExist() { - Table table = client.tables().table("non-existent-table"); + Table table = client.tables().table("\"non-existent-table\""); assertNull(table); } diff --git a/modules/client/src/test/java/org/apache/ignite/client/ReconnectTest.java b/modules/client/src/test/java/org/apache/ignite/client/ReconnectTest.java index f564bdf2ff2..aa24218e7a6 100644 --- a/modules/client/src/test/java/org/apache/ignite/client/ReconnectTest.java +++ b/modules/client/src/test/java/org/apache/ignite/client/ReconnectTest.java @@ -61,7 +61,7 @@ public void clientReconnectsToAnotherAddressOnNodeFail() { .retryPolicy(new RetryLimitPolicy().retryLimit(100)) .build(); - assertEquals("t", client.tables().tables().get(0).name()); + assertEquals("T", client.tables().tables().get(0).name().objectName()); server.close(); @@ -70,7 +70,7 @@ public void clientReconnectsToAnotherAddressOnNodeFail() { server2 = new TestServer(0, ignite2, null, null, null, AbstractClientTest.clusterId, null, 10950); - assertEquals("t2", client.tables().tables().get(0).name()); + assertEquals("T2", client.tables().tables().get(0).name().objectName()); } @Test @@ -85,7 +85,7 @@ public void testOperationFailsWhenAllServersFail() { .addresses("127.0.0.1:" + server.port(), "127.0.0.1:10960") .build(); - assertEquals("t", client.tables().tables().get(0).name()); + assertEquals("T", client.tables().tables().get(0).name().objectName()); server.close(); diff --git a/modules/client/src/test/java/org/apache/ignite/client/RetryPolicyTest.java b/modules/client/src/test/java/org/apache/ignite/client/RetryPolicyTest.java index fbb0262917e..b4b2b163c63 100644 --- a/modules/client/src/test/java/org/apache/ignite/client/RetryPolicyTest.java +++ b/modules/client/src/test/java/org/apache/ignite/client/RetryPolicyTest.java @@ -64,7 +64,7 @@ public void testNoRetryPolicySecondRequestFails() { initServer(reqId -> reqId % 3 == 0); try (var client = getClient(null)) { - assertEquals("t", client.tables().tables().get(0).name()); + assertEquals("T", client.tables().tables().get(0).name().objectName()); assertThrows(IgniteException.class, () -> client.tables().tables().get(0).name()); } } @@ -79,7 +79,7 @@ public void testRetryPolicyCompletesOperationWithoutException() { try (var client = getClient(plc)) { for (int i = 0; i < ITER; i++) { - assertEquals("t", client.tables().tables().get(0).name()); + assertEquals("T", client.tables().tables().get(0).name().objectName()); } assertEquals(ITER / 2 - 1, plc.invocations.size()); diff --git a/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java b/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java index 514f228490c..0379bbe12ad 100644 --- a/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java +++ b/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java @@ -46,6 +46,7 @@ import org.apache.ignite.internal.type.NativeTypes; import org.apache.ignite.lang.IgniteException; import org.apache.ignite.sql.IgniteSql; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.Table; import org.jetbrains.annotations.Nullable; @@ -69,7 +70,7 @@ public class FakeIgniteTables implements IgniteTablesInternal { public static final String BAD_TABLE_ERR = "Err!"; - private final ConcurrentHashMap tables = new ConcurrentHashMap<>(); + private final ConcurrentHashMap tables = new ConcurrentHashMap<>(); private final ConcurrentHashMap tablesById = new ConcurrentHashMap<>(); @@ -104,7 +105,7 @@ public Table createTable(String name) { public TableViewInternal createTable(String name, int id) { var newTable = getNewTable(name, id); - var oldTable = tables.putIfAbsent(name, newTable); + var oldTable = tables.putIfAbsent(QualifiedName.parse(name), newTable); if (oldTable != null) { throw new IgniteException(INTERNAL_ERR, TABLE_EXISTS); @@ -121,6 +122,15 @@ public TableViewInternal createTable(String name, int id) { * @param name Table name. */ public void dropTable(String name) { + dropTable(QualifiedName.parse(name)); + } + + /** + * Drops a table. + * + * @param name Table name. + */ + public void dropTable(QualifiedName name) { var table = tables.remove(name); if (table != null) { @@ -142,8 +152,8 @@ public CompletableFuture> tablesAsync() { /** {@inheritDoc} */ @Override - public Table table(String name) { - if (BAD_TABLE.equals(name)) { + public Table table(QualifiedName name) { + if (name.toCanonicalForm().contains(BAD_TABLE)) { throw new RuntimeException(BAD_TABLE_ERR); } @@ -158,7 +168,7 @@ public TableViewInternal table(int id) { /** {@inheritDoc} */ @Override - public CompletableFuture
tableAsync(String name) { + public CompletableFuture
tableAsync(QualifiedName name) { return completedFuture(table(name)); } @@ -170,13 +180,13 @@ public CompletableFuture tableAsync(int id) { /** {@inheritDoc} */ @Override - public TableViewInternal tableView(String name) { + public TableViewInternal tableView(QualifiedName name) { return tables.get(name); } /** {@inheritDoc} */ @Override - public CompletableFuture tableViewAsync(String name) { + public CompletableFuture tableViewAsync(QualifiedName name) { return completedFuture(tableView(name)); } @@ -226,8 +236,9 @@ private TableViewInternal getNewTable(String name, int id) { return BinaryRowConverter.keyExtractor(schema).extractColumns(row); }; + QualifiedName tableName = QualifiedName.parse(name); return new TableImpl( - new FakeInternalTable(name, id, keyExtractor, compute, placementDriver), + new FakeInternalTable(tableName, id, keyExtractor, compute, placementDriver), schemaReg, lockManager(), new SchemaVersions() { diff --git a/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeInternalTable.java b/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeInternalTable.java index c0992d2624b..ea01f00a1ee 100644 --- a/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeInternalTable.java +++ b/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeInternalTable.java @@ -60,6 +60,7 @@ import org.apache.ignite.internal.utils.PrimaryReplica; import org.apache.ignite.network.ClusterNode; import org.apache.ignite.network.NetworkAddress; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.ReceiverDescriptor; import org.jetbrains.annotations.Nullable; @@ -70,7 +71,7 @@ public class FakeInternalTable implements InternalTable, StreamerReceiverRunner public static final int PARTITIONS = 4; /** Table name. */ - private final String tableName; + private final QualifiedName tableName; /** Table ID. */ private final int tableId; @@ -96,7 +97,7 @@ public class FakeInternalTable implements InternalTable, StreamerReceiverRunner * @param placementDriver Placement driver. */ FakeInternalTable( - String tableName, + QualifiedName tableName, int tableId, ColumnsExtractor keyExtractor, IgniteCompute compute, @@ -124,7 +125,7 @@ public int tableId() { } @Override - public String name() { + public QualifiedName name() { return tableName; } diff --git a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItComputeBaseTest.java b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItComputeBaseTest.java index 59ee5adf7f5..d8622294db3 100644 --- a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItComputeBaseTest.java +++ b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItComputeBaseTest.java @@ -445,7 +445,7 @@ void executeColocatedThrowsTableNotFoundExceptionWhenTableDoesNotExist() { ); assertInstanceOf(TableNotFoundException.class, ex.getCause()); - assertThat(ex.getCause().getMessage(), containsString("The table does not exist [name=\"PUBLIC\".\"BAD_TABLE\"]")); + assertThat(ex.getCause().getMessage(), containsString("The table does not exist [name=PUBLIC.BAD_TABLE]")); } @ParameterizedTest(name = "local: {0}") diff --git a/modules/compute/src/main/java/org/apache/ignite/internal/compute/IgniteComputeImpl.java b/modules/compute/src/main/java/org/apache/ignite/internal/compute/IgniteComputeImpl.java index b28049c302d..b328264eaf9 100644 --- a/modules/compute/src/main/java/org/apache/ignite/internal/compute/IgniteComputeImpl.java +++ b/modules/compute/src/main/java/org/apache/ignite/internal/compute/IgniteComputeImpl.java @@ -63,7 +63,6 @@ import org.apache.ignite.internal.network.TopologyService; import org.apache.ignite.internal.placementdriver.PlacementDriver; import org.apache.ignite.internal.replicator.TablePartitionId; -import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.sql.engine.api.kill.CancellableOperationType; import org.apache.ignite.internal.sql.engine.api.kill.OperationKillHandler; import org.apache.ignite.internal.table.IgniteTablesInternal; @@ -77,8 +76,8 @@ import org.apache.ignite.lang.ErrorGroups.Compute; import org.apache.ignite.lang.IgniteException; import org.apache.ignite.lang.TableNotFoundException; -import org.apache.ignite.lang.util.IgniteNameUtils; import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.ReceiverDescriptor; import org.apache.ignite.table.Tuple; import org.apache.ignite.table.mapper.Mapper; @@ -442,12 +441,12 @@ public CompletableFuture> submitPartitionedIn } private CompletableFuture requiredTable(String tableName) { - String parsedName = IgniteNameUtils.parseSimpleName(tableName); + QualifiedName qualifiedName = QualifiedName.fromSimple(tableName); - return tables.tableViewAsync(parsedName) + return tables.tableViewAsync(qualifiedName) .thenApply(table -> { if (table == null) { - throw new TableNotFoundException(SqlCommon.DEFAULT_SCHEMA_NAME, parsedName); + throw new TableNotFoundException(qualifiedName); } return table; }); @@ -471,9 +470,10 @@ private CompletableFuture primaryReplicaForPartition(TableViewInter return topologyService.getById(replicaMeta.getLeaseholderId()); } + String tableName = table.name().toCanonicalForm(); throw new ComputeException( Compute.PRIMARY_REPLICA_RESOLVE_ERR, - "Can not find primary replica for [table=" + table.name() + ", partition=" + partitionIndex + "]." + "Can not find primary replica for [table=" + tableName + ", partition=" + partitionIndex + "]." ); }); } diff --git a/modules/compute/src/test/java/org/apache/ignite/internal/compute/IgniteComputeImplTest.java b/modules/compute/src/test/java/org/apache/ignite/internal/compute/IgniteComputeImplTest.java index 1f755700d65..1930d3f036d 100644 --- a/modules/compute/src/test/java/org/apache/ignite/internal/compute/IgniteComputeImplTest.java +++ b/modules/compute/src/test/java/org/apache/ignite/internal/compute/IgniteComputeImplTest.java @@ -63,6 +63,7 @@ import org.apache.ignite.lang.CancellationToken; import org.apache.ignite.network.ClusterNode; import org.apache.ignite.network.NetworkAddress; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.Tuple; import org.apache.ignite.table.mapper.Mapper; import org.jetbrains.annotations.Nullable; @@ -267,7 +268,7 @@ void executeBroadcastAsync() { } private void respondWhenAskForPrimaryReplica() { - when(igniteTables.tableViewAsync("TEST")).thenReturn(completedFuture(table)); + when(igniteTables.tableViewAsync(eq(QualifiedName.fromSimple("TEST")))).thenReturn(completedFuture(table)); ReplicaMeta replicaMeta = mock(ReplicaMeta.class); doReturn(randomUUID()).when(replicaMeta).getLeaseholderId(); CompletableFuture toBeReturned = completedFuture(replicaMeta); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlCommon.java b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlCommon.java index f04db58a5fb..8f351e893bb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlCommon.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlCommon.java @@ -17,15 +17,16 @@ package org.apache.ignite.internal.sql; +import org.apache.ignite.lang.util.IgniteNameUtils; import org.apache.ignite.table.QualifiedName; /** * Common SQL utilities. */ public final class SqlCommon { - // TODO https://issues.apache.org/jira/browse/IGNITE-24021: remove this. - /** Name of the default schema. */ - public static final String DEFAULT_SCHEMA_NAME = QualifiedName.DEFAULT_SCHEMA_NAME; + // TODO https://issues.apache.org/jira/browse/IGNITE-24021: parse identifier correctly. + /** Normalized name of the default schema. */ + public static final String DEFAULT_SCHEMA_NAME = IgniteNameUtils.parseSimpleName(QualifiedName.DEFAULT_SCHEMA_NAME); /** Default page size. */ public static final int DEFAULT_PAGE_SIZE = 1024; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/table/criteria/SqlSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/table/criteria/SqlSerializer.java index 9eedbc603ea..b42d2b4a66c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/table/criteria/SqlSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/table/criteria/SqlSerializer.java @@ -31,6 +31,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.ignite.internal.util.CollectionUtils; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.criteria.Column; import org.apache.ignite.table.criteria.Criteria; import org.apache.ignite.table.criteria.CriteriaVisitor; @@ -165,7 +166,7 @@ private void append(String delimiter, String prefix, String suffix, Criteria[] e */ public static class Builder { @Nullable - private String tableName; + private QualifiedName tableName; @Nullable private Collection columnNames; @@ -177,12 +178,12 @@ public static class Builder { private Criteria where; /** - * Sets the table name. Must be unquoted name or name is cast to upper case. + * Sets the table name. * * @param tableName Table name. * @return This builder instance. */ - public SqlSerializer.Builder tableName(String tableName) { + public SqlSerializer.Builder tableName(QualifiedName tableName) { this.tableName = tableName; return this; @@ -228,7 +229,7 @@ public SqlSerializer.Builder where(@Nullable Criteria where) { * @return SQL query text and arguments. */ public SqlSerializer build() { - if (nullOrBlank(tableName)) { + if (tableName == null) { throw new IllegalArgumentException("Table name can't be null or blank"); } @@ -244,7 +245,7 @@ public SqlSerializer build() { ser.append(" /*+ FORCE_INDEX(").append(normalizeIndexName(indexName)).append(") */"); } - ser.append(" * FROM ").append(quoteIfNeeded(tableName)); + ser.append(" * FROM ").append(tableName.toCanonicalForm()); if (where != null) { if (CollectionUtils.nullOrEmpty(columnNames)) { diff --git a/modules/core/src/main/java/org/apache/ignite/table/QualifiedNameHelper.java b/modules/core/src/main/java/org/apache/ignite/table/QualifiedNameHelper.java new file mode 100644 index 00000000000..47f9ce3c0b6 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/table/QualifiedNameHelper.java @@ -0,0 +1,47 @@ +/* + * 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.table; + +import org.apache.ignite.internal.sql.SqlCommon; +import org.apache.ignite.lang.util.IgniteNameUtils; +import org.jetbrains.annotations.Nullable; + +/** + * Utility class to provide direct access to internals of {@link QualifiedName}. + */ +public final class QualifiedNameHelper { + /** + * Return QualifiedName from a given schema and table names. + * + *

Given names are expected to be normalized, thus it's up to caller to invoke + * {@link IgniteNameUtils#parseSimpleName(String)} prior passing the names to this method. + * + * @param schemaName Normalized schema name. + * @param tableName Normalized table name. + * @return Qualified name. + */ + public static QualifiedName fromNormalized(@Nullable String schemaName, String tableName) { + assert tableName != null; + + return new QualifiedName(schemaName == null ? SqlCommon.DEFAULT_SCHEMA_NAME : schemaName, tableName); + } + + private QualifiedNameHelper() { + // No-op. + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/table/criteria/SqlSerializerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/table/criteria/SqlSerializerTest.java index b9ab76e6279..68cbe045fd6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/table/criteria/SqlSerializerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/table/criteria/SqlSerializerTest.java @@ -20,6 +20,7 @@ import static org.apache.ignite.internal.lang.IgniteStringFormatter.format; import static org.apache.ignite.internal.util.ArrayUtils.OBJECT_EMPTY_ARRAY; import static org.apache.ignite.lang.util.IgniteNameUtils.quote; +import static org.apache.ignite.table.QualifiedName.fromSimple; import static org.apache.ignite.table.criteria.Criteria.and; import static org.apache.ignite.table.criteria.Criteria.columnValue; import static org.apache.ignite.table.criteria.Criteria.equalTo; @@ -45,6 +46,8 @@ import java.util.Set; import java.util.function.Consumer; import java.util.stream.Stream; +import org.apache.ignite.internal.sql.SqlCommon; +import org.apache.ignite.table.QualifiedNameHelper; import org.apache.ignite.table.criteria.Criteria; import org.apache.ignite.table.criteria.Expression; import org.junit.jupiter.api.Test; @@ -93,7 +96,7 @@ static Stream testCondition() { @MethodSource void testCondition(Criteria criteria, String wherePart, Object[] arguments) { SqlSerializer ser = new SqlSerializer.Builder() - .tableName("test") + .tableName(fromSimple("test")) .columns(Set.of("A")) .where(criteria) .build(); @@ -146,7 +149,7 @@ static Stream testExpression() { @MethodSource void testExpression(Criteria criteria, String wherePart, Object[] arguments) { SqlSerializer ser = new SqlSerializer.Builder() - .tableName("test") + .tableName(fromSimple("test")) .columns(Set.of("A", "B", "C")) .where(criteria) .build(); @@ -176,7 +179,7 @@ void testColumnNameValidation() { IllegalArgumentException iae = assertThrows( IllegalArgumentException.class, () -> new SqlSerializer.Builder() - .tableName("test") + .tableName(fromSimple("test")) .where(columnValue("a", equalTo("a"))) .build() ); @@ -186,7 +189,7 @@ void testColumnNameValidation() { iae = assertThrows( IllegalArgumentException.class, () -> new SqlSerializer.Builder() - .tableName("test") + .tableName(fromSimple("test")) .columns(Set.of("B")) .where(columnValue("a", equalTo("a"))) .build() @@ -198,19 +201,19 @@ void testColumnNameValidation() { @Test void testQuote() { SqlSerializer ser = new SqlSerializer.Builder() - .tableName("Test") + .tableName(QualifiedNameHelper.fromNormalized(SqlCommon.DEFAULT_SCHEMA_NAME, "Test")) .columns(Set.of("Aa")) .where(columnValue(quote("Aa"), equalTo(1))) .build(); - assertThat(ser.toString(), endsWith(format("FROM {} WHERE {} = ?", quote("Test"), quote("Aa")))); + assertThat(ser.toString(), endsWith(format("FROM PUBLIC.\"Test\" WHERE {} = ?", quote("Aa")))); assertArrayEquals(new Object[]{1}, ser.getArguments()); } @Test void testIndexName() { SqlSerializer ser = new SqlSerializer.Builder() - .tableName("test") + .tableName(fromSimple("test")) .indexName("idx_a") .columns(Set.of("a")) .where(columnValue(quote("a"), equalTo(1))) @@ -220,7 +223,7 @@ void testIndexName() { assertArrayEquals(new Object[]{1}, ser.getArguments()); ser = new SqlSerializer.Builder() - .tableName("test") + .tableName(fromSimple("test")) .indexName("PUBLIC.idx_a") .columns(Set.of("a")) .where(columnValue(quote("a"), equalTo(1))) @@ -232,7 +235,7 @@ void testIndexName() { IllegalArgumentException iae = assertThrows( IllegalArgumentException.class, () -> new SqlSerializer.Builder() - .tableName("test") + .tableName(fromSimple("test")) .indexName("'idx_a'") .columns(Set.of("a")) .where(columnValue(quote("a"), equalTo(1))) @@ -244,7 +247,7 @@ void testIndexName() { iae = assertThrows( IllegalArgumentException.class, () -> new SqlSerializer.Builder() - .tableName("test") + .tableName(fromSimple("test")) .indexName("1idx_a") .columns(Set.of("a")) .where(columnValue(quote("a"), equalTo(1))) diff --git a/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceRecoveryTest.java b/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceRecoveryTest.java index 30dc07fe966..aef79c9b911 100644 --- a/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceRecoveryTest.java +++ b/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceRecoveryTest.java @@ -32,6 +32,7 @@ import org.apache.ignite.internal.storage.RowId; import org.apache.ignite.internal.table.distributed.TableManager; import org.apache.ignite.internal.test.WatchListenerInhibitor; +import org.apache.ignite.table.QualifiedName; import org.junit.jupiter.api.Test; /** @@ -80,7 +81,7 @@ void testPendingAssignmentsRecovery() throws InterruptedException { private static boolean containsPartition(Ignite node) { TableManager tableManager = unwrapTableManager(node.tables()); - MvPartitionStorage storage = tableManager.tableView("TEST") + MvPartitionStorage storage = tableManager.tableView(QualifiedName.fromSimple("TEST")) .internalTable() .storage() .getMvPartition(PARTITION_ID); diff --git a/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTriggersRecoveryTest.java b/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTriggersRecoveryTest.java index 65729316584..53441236cef 100644 --- a/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTriggersRecoveryTest.java +++ b/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTriggersRecoveryTest.java @@ -44,6 +44,7 @@ import org.apache.ignite.internal.storage.RowId; import org.apache.ignite.internal.table.distributed.TableManager; import org.apache.ignite.internal.test.WatchListenerInhibitor; +import org.apache.ignite.table.QualifiedName; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -251,7 +252,7 @@ private static CompletableFuture> partitionPendingAssignments( private static boolean containsPartition(Ignite node) { TableManager tableManager = unwrapTableManager(node.tables()); - MvPartitionStorage storage = tableManager.tableView("TEST") + MvPartitionStorage storage = tableManager.tableView(QualifiedName.fromSimple("TEST")) .internalTable() .storage() .getMvPartition(PARTITION_ID); diff --git a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java index 33ed44acbb5..ce0b81c30d8 100644 --- a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java +++ b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java @@ -310,7 +310,8 @@ private static Integer indexId(String indexName) { private static int tableId(String tableName) { IgniteImpl node = unwrapIgniteImpl(CLUSTER.aliveNode()); - CatalogTableDescriptor tableDescriptor = node.catalogManager().table(tableName, node.clock().nowLong()); + CatalogTableDescriptor tableDescriptor = node.catalogManager().table(SCHEMA_NAME, tableName, node.clock().nowLong() + ); assertNotNull(tableDescriptor, String.format("Table %s not found", tableName)); @@ -406,6 +407,6 @@ private static InternalTable internalTable(Ignite node, String tableName) { * @param indexName Index name. */ private static @Nullable CatalogIndexDescriptor getIndexDescriptor(IgniteImpl node, String indexName) { - return node.catalogManager().aliveIndex(indexName, node.clock().nowLong()); + return node.catalogManager().aliveIndex(SCHEMA_NAME, indexName, node.clock().nowLong()); } } diff --git a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItDropIndexMultipleNodesTest.java b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItDropIndexMultipleNodesTest.java index 7f458c75192..8780e09368d 100644 --- a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItDropIndexMultipleNodesTest.java +++ b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItDropIndexMultipleNodesTest.java @@ -239,7 +239,7 @@ private static int createIndex() { IgniteImpl node = unwrapIgniteImpl(CLUSTER.aliveNode()); - return node.catalogManager().aliveIndex(INDEX_NAME, node.clock().nowLong()).id(); + return node.catalogManager().aliveIndex(SCHEMA_NAME, INDEX_NAME, node.clock().nowLong()).id(); } private static void createIndexBlindly() { diff --git a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexAndIndexStorageDestructionTest.java b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexAndIndexStorageDestructionTest.java index f9b82dfb5b3..ceeb83b29be 100644 --- a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexAndIndexStorageDestructionTest.java +++ b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexAndIndexStorageDestructionTest.java @@ -31,6 +31,7 @@ import org.apache.ignite.internal.ClusterPerTestIntegrationTest; import org.apache.ignite.internal.app.IgniteImpl; import org.apache.ignite.internal.catalog.descriptors.CatalogIndexDescriptor; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.storage.index.IndexStorage; import org.apache.ignite.internal.storage.pagememory.index.AbstractPageMemoryIndexStorage; import org.apache.ignite.internal.storage.rocksdb.index.AbstractRocksDbIndexStorage; @@ -50,6 +51,7 @@ * Tests about accessing destroyed index storages. */ class ItIndexAndIndexStorageDestructionTest extends ClusterPerTestIntegrationTest { + private static final String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; private static final String TABLE_NAME = "TEST_TABLE"; private static final String INDEX_NAME = "TEST_INDEX"; @@ -99,7 +101,8 @@ private void initiateIndexStoragesDestruction(TableImpl table, String indexName) private int indexId(String indexName) { IgniteImpl igniteImpl = unwrapIgniteImpl(node); - CatalogIndexDescriptor indexDescriptor = igniteImpl.catalogManager().aliveIndex(indexName, igniteImpl.clock().nowLong()); + long timestamp = igniteImpl.clock().nowLong(); + CatalogIndexDescriptor indexDescriptor = igniteImpl.catalogManager().aliveIndex(SCHEMA_NAME, indexName, timestamp); assertThat(indexDescriptor, is(notNullValue())); return indexDescriptor.id(); diff --git a/modules/platforms/cpp/tests/client-test/column_order_test.cpp b/modules/platforms/cpp/tests/client-test/column_order_test.cpp index 4fdb033bc80..b0924d01810 100644 --- a/modules/platforms/cpp/tests/client-test/column_order_test.cpp +++ b/modules/platforms/cpp/tests/client-test/column_order_test.cpp @@ -27,7 +27,8 @@ using namespace ignite; -#define TEST_TABLE_NAME "column_order_test" +// TODO https://issues.apache.org/jira/browse/IGNITE-24261 check lowercased name +#define TEST_TABLE_NAME "COLUMN_ORDER_TEST" /** * Test suite. diff --git a/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h b/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h index 2d6611677c2..cca7a641ed1 100644 --- a/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h +++ b/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h @@ -38,9 +38,11 @@ using namespace std::string_view_literals; */ class ignite_runner_suite : public virtual ::testing::Test { public: - static constexpr std::string_view TABLE_1 = "tbl1"sv; - static constexpr std::string_view TABLE_NAME_ALL_COLUMNS = "tbl_all_columns"sv; - static constexpr std::string_view TABLE_NAME_ALL_COLUMNS_SQL = "tbl_all_columns_sql"sv; + // TODO https://issues.apache.org/jira/browse/IGNITE-24261 revert changing named to uppercase + static constexpr std::string_view TABLE_1 = "TBL1"sv; + static constexpr std::string_view TABLE_NAME_ALL_COLUMNS = "TBL_ALL_COLUMNS"sv; + static constexpr std::string_view TABLE_NAME_ALL_COLUMNS_SQL = "TBL_ALL_COLUMNS_SQL"sv; + inline static const std::string PLATFORM_TEST_NODE_RUNNER = "org.apache.ignite.internal.runner.app.PlatformTestNodeRunner"; diff --git a/modules/platforms/cpp/tests/client-test/transactions_test.cpp b/modules/platforms/cpp/tests/client-test/transactions_test.cpp index 7750703cb21..902e20e762c 100644 --- a/modules/platforms/cpp/tests/client-test/transactions_test.cpp +++ b/modules/platforms/cpp/tests/client-test/transactions_test.cpp @@ -27,6 +27,9 @@ using namespace ignite; +// TODO https://issues.apache.org/jira/browse/IGNITE-24261 check lowercased name +#define TEST_TABLE_NAME "TBL1" + /** * Test suite. */ @@ -68,7 +71,7 @@ TEST_F(transactions_test, empty_transaction_commit) { } TEST_F(transactions_test, commit_updates_data) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -86,7 +89,7 @@ TEST_F(transactions_test, commit_updates_data) { } TEST_F(transactions_test, rollback_does_not_update_data) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -102,7 +105,7 @@ TEST_F(transactions_test, rollback_does_not_update_data) { // TODO https://issues.apache.org/jira/browse/IGNITE-22057 TEST_F(transactions_test, DISABLED_destruction_does_not_update_data) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); { auto tx = m_client.get_transactions().begin(); @@ -117,7 +120,7 @@ TEST_F(transactions_test, DISABLED_destruction_does_not_update_data) { } TEST_F(transactions_test, non_committed_data_visible_for_tx) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -133,7 +136,7 @@ TEST_F(transactions_test, non_committed_data_visible_for_tx) { } TEST_F(transactions_test, sql_commit) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -151,7 +154,7 @@ TEST_F(transactions_test, sql_commit) { } TEST_F(transactions_test, sql_rollback) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -194,7 +197,7 @@ TEST_F(transactions_test, rollback_after_rollback_works) { } TEST_F(transactions_test, record_view_upsert_all) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -217,7 +220,7 @@ TEST_F(transactions_test, record_view_upsert_all) { } TEST_F(transactions_test, record_view_get_and_upsert) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -241,7 +244,7 @@ TEST_F(transactions_test, record_view_get_and_upsert) { } TEST_F(transactions_test, record_view_insert) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -263,7 +266,7 @@ TEST_F(transactions_test, record_view_insert) { } TEST_F(transactions_test, record_view_insert_all) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -286,7 +289,7 @@ TEST_F(transactions_test, record_view_insert_all) { } TEST_F(transactions_test, record_view_replace) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -305,7 +308,7 @@ TEST_F(transactions_test, record_view_replace) { } TEST_F(transactions_test, record_view_replace_exact) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -324,7 +327,7 @@ TEST_F(transactions_test, record_view_replace_exact) { } TEST_F(transactions_test, record_view_get_and_replace) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto tx = m_client.get_transactions().begin(); @@ -346,7 +349,7 @@ TEST_F(transactions_test, record_view_get_and_replace) { } TEST_F(transactions_test, record_view_remove) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto value0 = get_tuple(42, "Lorem ipsum"); record_view.insert(nullptr, value0); @@ -362,7 +365,7 @@ TEST_F(transactions_test, record_view_remove) { } TEST_F(transactions_test, record_view_remove_exact) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto value0 = get_tuple(42, "Lorem ipsum"); record_view.insert(nullptr, value0); @@ -378,7 +381,7 @@ TEST_F(transactions_test, record_view_remove_exact) { } TEST_F(transactions_test, record_view_get_and_remove) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto value0 = get_tuple(42, "Lorem ipsum"); record_view.insert(nullptr, value0); @@ -402,7 +405,7 @@ TEST_F(transactions_test, record_view_get_and_remove) { } TEST_F(transactions_test, record_view_remove_all) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto value0 = get_tuple(42, "Lorem ipsum"); record_view.insert(nullptr, value0); @@ -418,7 +421,7 @@ TEST_F(transactions_test, record_view_remove_all) { } TEST_F(transactions_test, record_view_remove_all_exact) { - auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view(); + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); auto value0 = get_tuple(42, "Lorem ipsum"); record_view.insert(nullptr, value0); diff --git a/modules/platforms/cpp/tests/odbc-test/odbc_suite.h b/modules/platforms/cpp/tests/odbc-test/odbc_suite.h index 11015c99b54..e94c2323ed3 100644 --- a/modules/platforms/cpp/tests/odbc-test/odbc_suite.h +++ b/modules/platforms/cpp/tests/odbc-test/odbc_suite.h @@ -43,9 +43,10 @@ namespace ignite { */ class odbc_suite : public virtual ::testing::Test, public odbc_connection { public: - static inline const std::string TABLE_1 = "tbl1"; - static inline const std::string TABLE_NAME_ALL_COLUMNS = "tbl_all_columns"; - static inline const std::string TABLE_NAME_ALL_COLUMNS_SQL = "tbl_all_columns_sql"; + // TODO https://issues.apache.org/jira/browse/IGNITE-24261 revert changing named to uppercase + static inline const std::string TABLE_1 = "TBL1"; + static inline const std::string TABLE_NAME_ALL_COLUMNS = "TBL_ALL_COLUMNS"; + static inline const std::string TABLE_NAME_ALL_COLUMNS_SQL = "TBL_ALL_COLUMNS_SQL"; static constexpr const char *KEY_COLUMN = "key"; static constexpr const char *VAL_COLUMN = "val"; diff --git a/modules/platforms/dotnet/Apache.Extensions.Caching.Ignite.Tests/IgniteDistributedCacheTests.cs b/modules/platforms/dotnet/Apache.Extensions.Caching.Ignite.Tests/IgniteDistributedCacheTests.cs index 1016c095ffb..b555da85eaa 100644 --- a/modules/platforms/dotnet/Apache.Extensions.Caching.Ignite.Tests/IgniteDistributedCacheTests.cs +++ b/modules/platforms/dotnet/Apache.Extensions.Caching.Ignite.Tests/IgniteDistributedCacheTests.cs @@ -151,9 +151,10 @@ public async Task TestExistingTable() await Client.Sql.ExecuteAsync(null, $"INSERT INTO {tableName} (K, V) VALUES ('x', x'010203')"); + // TODO https://issues.apache.org/jira/browse/IGNITE-24258: Remove unnecessary uppercasing for tableName. var options = new IgniteDistributedCacheOptions { - TableName = tableName, + TableName = tableName.ToUpperInvariant(), KeyColumnName = "K", ValueColumnName = "V" }; @@ -170,7 +171,8 @@ public async Task TestNonExistingTable() await Client.Sql.ExecuteAsync(null, $"DROP TABLE IF EXISTS {tableName}"); - IDistributedCache cache = GetCache(new() { TableName = tableName }); + // TODO https://issues.apache.org/jira/browse/IGNITE-24258: Remove unnecessary uppercasing for tableName. + IDistributedCache cache = GetCache(new() { TableName = tableName.ToUpperInvariant() }); await cache.SetAsync("x", [1]); Assert.AreEqual(new[] { 1 }, await cache.GetAsync("x")); @@ -181,7 +183,8 @@ public async Task TestCustomTableAndColumnNames() { var cacheOptions = new IgniteDistributedCacheOptions { - TableName = nameof(TestCustomTableAndColumnNames), + // TODO https://issues.apache.org/jira/browse/IGNITE-24258: Remove unnecessary uppercasing for tableName. + TableName = nameof(TestCustomTableAndColumnNames).ToUpperInvariant(), KeyColumnName = "_K", ValueColumnName = "_V" }; diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/ClientSocketTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/ClientSocketTests.cs index e70800fc226..e1ee3d3b0a1 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/ClientSocketTests.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/ClientSocketTests.cs @@ -38,7 +38,7 @@ public async Task TestConnectAndSendRequestReturnsResponse() using var socket = await ClientSocket.ConnectAsync(GetEndPoint(), new(), Listener); using var requestWriter = ProtoCommon.GetMessageWriter(); - requestWriter.MessageWriter.Write("non-existent-table"); + requestWriter.MessageWriter.Write("\"non-existent-table\""); using var response = await socket.DoOutInOpAsync(ClientOp.TableGet, requestWriter); Assert.IsTrue(response.GetReader().TryReadNil()); diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs index de2ab5d7f63..f4447ea49a1 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs @@ -345,7 +345,9 @@ public async Task TestExecuteColocatedUpdatesTableCacheOnTableDrop([Values(false { // Create table and use it in ExecuteColocated. var nodes = await GetNodeAsync(0); - var tableNameExec = await Client.Compute.SubmitAsync(nodes, CreateTableJob, "drop_me"); + + // TODO https://issues.apache.org/jira/browse/IGNITE-24258 revert change that had uppercased names. + var tableNameExec = await Client.Compute.SubmitAsync(nodes, CreateTableJob, "DROP_ME"); var tableName = await tableNameExec.GetResultAsync(); try diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/FakeServer.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/FakeServer.cs index b0d60514c78..2336ad7d5ff 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/FakeServer.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/FakeServer.cs @@ -46,11 +46,11 @@ public sealed class FakeServer : IgniteServerBase { public const string Err = "Err!"; - public const string ExistingTableName = "tbl1"; + public const string ExistingTableName = "TBL1"; - public const string CompositeKeyTableName = "tbl2"; + public const string CompositeKeyTableName = "TBL2"; - public const string CustomColocationKeyTableName = "tbl3"; + public const string CustomColocationKeyTableName = "TBL3"; public const string GetDetailsJob = "get-details"; diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.KvView.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.KvView.cs index aba2deb4385..76501a1d04e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.KvView.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.KvView.cs @@ -33,22 +33,22 @@ public partial class LinqSqlGenerationTests { [Test] public void TestSelectPrimitiveKeyColumnKv() => - AssertSqlKv("select _T0.VAL from PUBLIC.tbl1 as _T0", q => q.Select(x => x.Value.Val).ToList()); + AssertSqlKv("select _T0.VAL from PUBLIC.TBL1 as _T0", q => q.Select(x => x.Value.Val).ToList()); [Test] public void TestSelectPocoValColumnKv() => - AssertSqlKv("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0", q => q.Select(x => x.Value).ToList()); + AssertSqlKv("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0", q => q.Select(x => x.Value).ToList()); [Test] public void TestSelectTwoColumnsKv() => AssertSqlKv( - "select (_T0.KEY + ?) as KEY, _T0.VAL from PUBLIC.tbl1 as _T0", + "select (_T0.KEY + ?) as KEY, _T0.VAL from PUBLIC.TBL1 as _T0", q => q.Select(x => new { Key = x.Key.Key + 1, x.Value.Val }).ToList()); [Test] public void TestSelectAllColumnsCustomNamesKv() => AssertSql( - "select _T0.\"KEY\", _T0.\"VAL\" from PUBLIC.tbl1 as _T0", + "select _T0.\"KEY\", _T0.\"VAL\" from PUBLIC.TBL1 as _T0", tbl => tbl.GetKeyValueView().AsQueryable().ToList()); [Test] @@ -57,21 +57,21 @@ public void TestSelectSameColumnFromPairKeyAndValKv() // We avoid selecting same column twice if it is included in both Key and Value parts, // but if the user requests it explicitly, we keep it. AssertSqlKv( - "select _T0.KEY, _T0.KEY from PUBLIC.tbl1 as _T0", + "select _T0.KEY, _T0.KEY from PUBLIC.TBL1 as _T0", q => q.Select(x => new { Key1 = x.Key.Key, Key2 = x.Value.Key }).ToList()); } [Test] public void TestSelectEntirePairKv() => - AssertSqlKv("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0 where (_T0.KEY > ?)", q => q.Where(x => x.Key.Key > 1).ToList()); + AssertSqlKv("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0 where (_T0.KEY > ?)", q => q.Where(x => x.Key.Key > 1).ToList()); [Test] public void TestSelectPairKeyKv() => - AssertSqlKv("select _T0.KEY from PUBLIC.tbl1 as _T0", q => q.Select(x => x.Key).ToList()); + AssertSqlKv("select _T0.KEY from PUBLIC.TBL1 as _T0", q => q.Select(x => x.Key).ToList()); [Test] public void TestSelectPairValKv() => - AssertSqlKv("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0", q => q.Select(x => x.Value).ToList()); + AssertSqlKv("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0", q => q.Select(x => x.Value).ToList()); [Test] public void TestPrimitiveTypeMappingNotSupportedKv() diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.MemberInit.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.MemberInit.cs index b441e4f78bd..85ce750b1a4 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.MemberInit.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.MemberInit.cs @@ -27,17 +27,17 @@ public partial class LinqSqlGenerationTests { [Test] public void TestSelectMemberInitOnlyProperties() => AssertSql( - "select _T0.KEY as KEY, _T0.VAL as VALUE from PUBLIC.tbl1 as _T0", + "select _T0.KEY as KEY, _T0.VAL as VALUE from PUBLIC.TBL1 as _T0", q => q.Select(p => new CustomProjection {Key = p.Key, Value = p.Val}).ToList()); [Test] public void TestSelectMemberInitOnlyCtor() => AssertSql( - "select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0", + "select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0", q => q.Select(p => new CustomProjectionRecord(p.Key, p.Val)).ToList()); [Test] public void TestSelectMemberInitCtorAndProps() => AssertSql( - "select _T0.KEY, _T0.VAL, _T0.VAL as VAL1 from PUBLIC.tbl1 as _T0", + "select _T0.KEY, _T0.VAL, _T0.VAL as VAL1 from PUBLIC.TBL1 as _T0", q => q.Select(p => new CustomProjectionRecord(p.Key, p.Val) { Val1 = p.Val }).ToList()); // ReSharper disable UnusedAutoPropertyAccessor.Local diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.cs index 48c18dc6384..f44f5fb29cb 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.cs @@ -40,115 +40,115 @@ public partial class LinqSqlGenerationTests [Test] public void TestSelectOneColumn() => - AssertSql("select _T0.KEY from PUBLIC.tbl1 as _T0", q => q.Select(x => x.Key).ToList()); + AssertSql("select _T0.KEY from PUBLIC.TBL1 as _T0", q => q.Select(x => x.Key).ToList()); [Test] public void TestSelectAllColumns() => - AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0", q => q.ToList()); + AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0", q => q.ToList()); [Test] public void TestSelectAllColumnsOneColumnPoco() => AssertSql( - "select _T0.KEY from PUBLIC.tbl1 as _T0", + "select _T0.KEY from PUBLIC.TBL1 as _T0", tbl => tbl.GetRecordView().AsQueryable().ToList()); [Test] public void TestSelectAllColumnsCustomNames() => AssertSql( - "select _T0.\"KEY\", _T0.\"VAL\" from PUBLIC.tbl1 as _T0", + "select _T0.\"KEY\", _T0.\"VAL\" from PUBLIC.TBL1 as _T0", tbl => tbl.GetRecordView().AsQueryable().ToList()); [Test] public void TestSum() => - AssertSql("select sum(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.Sum(x => x.Key)); + AssertSql("select sum(_T0.KEY) from PUBLIC.TBL1 as _T0", q => q.Sum(x => x.Key)); [Test] public void TestSumAsync() => - AssertSql("select sum(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.SumAsync(x => x.Key).Result); + AssertSql("select sum(_T0.KEY) from PUBLIC.TBL1 as _T0", q => q.SumAsync(x => x.Key).Result); [Test] public void TestAvg() => - AssertSql("select avg(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.Average(x => x.Key)); + AssertSql("select avg(_T0.KEY) from PUBLIC.TBL1 as _T0", q => q.Average(x => x.Key)); [Test] public void TestAvgAsync() => - AssertSql("select avg(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.AverageAsync(x => x.Key).Result); + AssertSql("select avg(_T0.KEY) from PUBLIC.TBL1 as _T0", q => q.AverageAsync(x => x.Key).Result); [Test] public void TestMin() => - AssertSql("select min(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.Min(x => x.Key)); + AssertSql("select min(_T0.KEY) from PUBLIC.TBL1 as _T0", q => q.Min(x => x.Key)); [Test] public void TestMinAsync() => - AssertSql("select min(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.MinAsync(x => x.Key).Result); + AssertSql("select min(_T0.KEY) from PUBLIC.TBL1 as _T0", q => q.MinAsync(x => x.Key).Result); [Test] public void TestMax() => - AssertSql("select max(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.Max(x => x.Key)); + AssertSql("select max(_T0.KEY) from PUBLIC.TBL1 as _T0", q => q.Max(x => x.Key)); [Test] public void TestMaxAsync() => - AssertSql("select max(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.MaxAsync(x => x.Key).Result); + AssertSql("select max(_T0.KEY) from PUBLIC.TBL1 as _T0", q => q.MaxAsync(x => x.Key).Result); [Test] public void TestCount() => - AssertSql("select count(*) from PUBLIC.tbl1 as _T0", q => q.Count()); + AssertSql("select count(*) from PUBLIC.TBL1 as _T0", q => q.Count()); [Test] public void TestCountAsync() => - AssertSql("select count(*) from PUBLIC.tbl1 as _T0", q => q.CountAsync().Result); + AssertSql("select count(*) from PUBLIC.TBL1 as _T0", q => q.CountAsync().Result); [Test] public void TestLongCount() => - AssertSql("select count(*) from PUBLIC.tbl1 as _T0", q => q.LongCount()); + AssertSql("select count(*) from PUBLIC.TBL1 as _T0", q => q.LongCount()); [Test] public void TestLongCountAsync() => - AssertSql("select count(*) from PUBLIC.tbl1 as _T0", q => q.LongCountAsync().Result); + AssertSql("select count(*) from PUBLIC.TBL1 as _T0", q => q.LongCountAsync().Result); [Test] public void TestDistinct() => - AssertSql("select distinct _T0.VAL from PUBLIC.tbl1 as _T0", q => q.Select(x => x.Val).Distinct().ToArray()); + AssertSql("select distinct _T0.VAL from PUBLIC.TBL1 as _T0", q => q.Select(x => x.Val).Distinct().ToArray()); [Test] public void TestAll() => AssertSql( - "select not exists (select 1 from PUBLIC.tbl1 as _T0 where not (_T0.KEY > ?))", + "select not exists (select 1 from PUBLIC.TBL1 as _T0 where not (_T0.KEY > ?))", q => q.All(x => x.Key > 10)); [Test] public void TestAllAsync() => AssertSql( - "select not exists (select 1 from PUBLIC.tbl1 as _T0 where not (_T0.KEY > ?))", + "select not exists (select 1 from PUBLIC.TBL1 as _T0 where not (_T0.KEY > ?))", q => q.AllAsync(x => x.Key > 10).Result); [Test] public void TestAllWithWhere() => AssertSql( - "select not exists (select 1 from PUBLIC.tbl1 as _T0 where (_T0.VAL IS DISTINCT FROM ?) and not (_T0.KEY > ?))", + "select not exists (select 1 from PUBLIC.TBL1 as _T0 where (_T0.VAL IS DISTINCT FROM ?) and not (_T0.KEY > ?))", q => q.Where(x => x.Val != "1").All(x => x.Key > 10)); [Test] public void TestAny() => - AssertSql("select exists (select 1 from PUBLIC.tbl1 as _T0)", q => q.Any()); + AssertSql("select exists (select 1 from PUBLIC.TBL1 as _T0)", q => q.Any()); [Test] public void TestAnyAsync() => - AssertSql("select exists (select 1 from PUBLIC.tbl1 as _T0)", q => q.AnyAsync().Result); + AssertSql("select exists (select 1 from PUBLIC.TBL1 as _T0)", q => q.AnyAsync().Result); [Test] public void TestAnyWithPredicate() => - AssertSql("select exists (select 1 from PUBLIC.tbl1 as _T0 where (_T0.KEY > ?))", q => q.Any(x => x.Key > 10)); + AssertSql("select exists (select 1 from PUBLIC.TBL1 as _T0 where (_T0.KEY > ?))", q => q.Any(x => x.Key > 10)); [Test] public void TestAnyAsyncWithPredicate() => - AssertSql("select exists (select 1 from PUBLIC.tbl1 as _T0 where (_T0.KEY > ?))", q => q.AnyAsync(x => x.Key > 10).Result); + AssertSql("select exists (select 1 from PUBLIC.TBL1 as _T0 where (_T0.KEY > ?))", q => q.AnyAsync(x => x.Key > 10).Result); [Test] public void TestSelectOrderByOffsetLimit() => AssertSql( "select _T0.KEY, _T0.VAL, (_T0.KEY + ?) as KEY2 " + - "from PUBLIC.tbl1 as _T0 " + + "from PUBLIC.TBL1 as _T0 " + "order by (_T0.KEY + ?) asc, _T0.VAL desc " + "limit ? offset ?", q => q.Select(x => new { x.Key, x.Val, Key2 = x.Key + 1}) @@ -160,41 +160,41 @@ public void TestSelectOrderByOffsetLimit() => [Test] public void TestFirst() => - AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0 limit 1", q => q.First()); + AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0 limit 1", q => q.First()); [Test] public void TestFirstAsync() => - AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0 limit 1", q => q.FirstAsync().Result); + AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0 limit 1", q => q.FirstAsync().Result); [Test] public void TestFirstOrDefault() => - AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0 limit 1", q => q.FirstOrDefault()); + AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0 limit 1", q => q.FirstOrDefault()); [Test] public void TestFirstOrDefaultAsync() => - AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0 limit 1", q => q.FirstOrDefaultAsync().Result); + AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0 limit 1", q => q.FirstOrDefaultAsync().Result); [Test] public void TestSingle() => - AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0 limit 2", q => q.Single()); + AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0 limit 2", q => q.Single()); [Test] public void TestSingleAsync() => - AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0 limit 2", q => q.SingleAsync().Result); + AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0 limit 2", q => q.SingleAsync().Result); [Test] public void TestSingleOrDefault() => - AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0 limit 2", q => q.SingleOrDefault()); + AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0 limit 2", q => q.SingleOrDefault()); [Test] public void TestSingleOrDefaultAsync() => - AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0 limit 2", q => q.SingleOrDefaultAsync().Result); + AssertSql("select _T0.KEY, _T0.VAL from PUBLIC.TBL1 as _T0 limit 2", q => q.SingleOrDefaultAsync().Result); [Test] public void TestOffsetLimitFirst() => AssertSql( "select _T0.KEY, _T0.VAL " + - "from PUBLIC.tbl1 as _T0 " + + "from PUBLIC.TBL1 as _T0 " + "limit 1 offset ?", q => q.Skip(2).Take(3).First()); @@ -202,7 +202,7 @@ public void TestOffsetLimitFirst() => public void TestOffsetLimitSingle() => AssertSql( "select _T0.KEY, _T0.VAL " + - "from PUBLIC.tbl1 as _T0 " + + "from PUBLIC.TBL1 as _T0 " + "limit 2 offset ?", q => q.Skip(2).Take(3).Single()); @@ -229,7 +229,7 @@ public void TestLimitMultipleNotSupported() [Test] public void TestSelectOrderDistinct() => AssertSql( - "select * from (select distinct _T0.KEY, (_T0.KEY + ?) as KEY2 from PUBLIC.tbl1 as _T0) as _T1 order by _T1.KEY2 asc", + "select * from (select distinct _T0.KEY, (_T0.KEY + ?) as KEY2 from PUBLIC.TBL1 as _T0) as _T1 order by _T1.KEY2 asc", q => q.Select(x => new { x.Key, Key2 = x.Key + 1}) .Distinct() .OrderBy(x => x.Key2) @@ -263,7 +263,7 @@ public void TestCustomQueryableOptions() public void TestGroupBySubQuery() { AssertSql( - "select (_T0.KEY + ?) as _G0, count(*) as CNT from PUBLIC.tbl1 as _T0 group by _G0", + "select (_T0.KEY + ?) as _G0, count(*) as CNT from PUBLIC.TBL1 as _T0 group by _G0", q => q.Select(x => new { x.Key, Key2 = x.Key + 1 }) .GroupBy(x => x.Key2) .Select(g => new { g.Key, Cnt = g.Count() }) @@ -322,8 +322,8 @@ public void TestRecordViewKeyValuePairNotSupported() [Test] public void TestUnion() => AssertSql( - "select (_T0.KEY + ?) as KEY, _T0.VAL from PUBLIC.tbl1 as _T0 " + - "union (select (_T1.KEY + ?) as KEY, _T1.VAL from PUBLIC.tbl1 as _T1)", + "select (_T0.KEY + ?) as KEY, _T0.VAL from PUBLIC.TBL1 as _T0 " + + "union (select (_T1.KEY + ?) as KEY, _T1.VAL from PUBLIC.TBL1 as _T1)", q => q.Select(x => new { Key = x.Key + 1, x.Val }) .Union(q.Select(x => new { Key = x.Key + 100, x.Val })) .ToList()); @@ -331,8 +331,8 @@ public void TestUnion() => [Test] public void TestIntersect() => AssertSql( - "select (_T0.KEY + ?) as KEY, concat(_T0.VAL, ?) as VAL from PUBLIC.tbl1 as _T0 " + - "intersect (select (_T1.KEY + ?) as KEY, concat(_T1.VAL, ?) as VAL from PUBLIC.tbl1 as _T1)", + "select (_T0.KEY + ?) as KEY, concat(_T0.VAL, ?) as VAL from PUBLIC.TBL1 as _T0 " + + "intersect (select (_T1.KEY + ?) as KEY, concat(_T1.VAL, ?) as VAL from PUBLIC.TBL1 as _T1)", q => q.Select(x => new { Key = x.Key + 1, Val = x.Val + "_" }) .Intersect(q.Select(x => new { Key = x.Key + 100, Val = x.Val + "!" })) .ToList()); @@ -340,7 +340,7 @@ public void TestIntersect() => [Test] public void TestExcept() => AssertSql( - "select (_T0.KEY + ?) from PUBLIC.tbl1 as _T0 except (select (_T1.KEY + ?) from PUBLIC.tbl1 as _T1)", + "select (_T0.KEY + ?) from PUBLIC.TBL1 as _T0 except (select (_T1.KEY + ?) from PUBLIC.TBL1 as _T1)", q => q.Select(x => x.Key + 1) .Except(q.Select(x => x.Key + 5)) .ToList()); @@ -354,7 +354,7 @@ public void TestQueryToString() const string expectedQueryText = "select _T0.VAL, _T0.KEY " + - "from PUBLIC.tbl1 as _T0 " + + "from PUBLIC.TBL1 as _T0 " + "where ((_T0.KEY IS NOT DISTINCT FROM ?) and (_T0.VAL IS DISTINCT FROM ?))"; const string expectedToString = @@ -368,30 +368,30 @@ public void TestQueryToString() [Test] public void TestExecuteDelete() => - AssertSql("delete from PUBLIC.tbl1 as _T0", q => q.ExecuteDeleteAsync().Result); + AssertSql("delete from PUBLIC.TBL1 as _T0", q => q.ExecuteDeleteAsync().Result); [Test] public void TestExecuteDeleteWithCondition() => AssertSql( - "delete from PUBLIC.tbl1 as _T0 where ((_T0.KEY IS NOT DISTINCT FROM ?) and (_T0.VAL IS DISTINCT FROM ?))", + "delete from PUBLIC.TBL1 as _T0 where ((_T0.KEY IS NOT DISTINCT FROM ?) and (_T0.VAL IS DISTINCT FROM ?))", q => q.Where(x => x.Key == 3 && x.Val != "v-2").ExecuteDeleteAsync().Result); [Test] public void TestExecuteDeleteWithInlineCondition() => AssertSql( - "delete from PUBLIC.tbl1 as _T0 where ((_T0.KEY IS NOT DISTINCT FROM ?) and (_T0.VAL IS DISTINCT FROM ?))", + "delete from PUBLIC.TBL1 as _T0 where ((_T0.KEY IS NOT DISTINCT FROM ?) and (_T0.VAL IS DISTINCT FROM ?))", q => q.ExecuteDeleteAsync(x => x.Key == 3 && x.Val != "v-2").Result); [Test] public void TestExecuteUpdateWithConstantValue() => AssertSql( - "update PUBLIC.tbl1 as _T0 set VAL = ? where (_T0.KEY IS NOT DISTINCT FROM ?)", + "update PUBLIC.TBL1 as _T0 set VAL = ? where (_T0.KEY IS NOT DISTINCT FROM ?)", q => q.Where(x => x.Key == 3).ExecuteUpdateAsync(row => row.SetProperty(x => x.Val, "1")).Result); [Test] public void TestExecuteUpdateWithComputedValue() => AssertSql( - "update PUBLIC.tbl1 as _T0 set VAL = concat(concat(_T0.VAL, ?), cast(_T0.KEY as varchar)) where (_T0.KEY > ?)", + "update PUBLIC.TBL1 as _T0 set VAL = concat(concat(_T0.VAL, ?), cast(_T0.KEY as varchar)) where (_T0.KEY > ?)", q => q.Where(x => x.Key > 3).ExecuteUpdateAsync(row => row.SetProperty(x => x.Val, x => x.Val + "_" + x.Key)).Result); [Test] @@ -400,8 +400,8 @@ public void TestExecuteUpdateWithComputedValueFromSubquery() IQueryable q2 = _table.GetRecordView().AsQueryable(); AssertSql( - "update PUBLIC.tbl1 as _T0 " + - "set VAL = (select concat(?, cast(_T1.KEY as varchar)) from PUBLIC.tbl1 as _T1 where (_T1.KEY IS NOT DISTINCT FROM (_T0.KEY + ?)) limit 1) " + + "update PUBLIC.TBL1 as _T0 " + + "set VAL = (select concat(?, cast(_T1.KEY as varchar)) from PUBLIC.TBL1 as _T1 where (_T1.KEY IS NOT DISTINCT FROM (_T0.KEY + ?)) limit 1) " + "where (_T0.KEY > ?)", q => q.Where(x => x.Key > 3).ExecuteUpdateAsync( row => row.SetProperty( @@ -412,7 +412,7 @@ public void TestExecuteUpdateWithComputedValueFromSubquery() [Test] public void TestExecuteUpdateWithMultipleSetters() => AssertSql( - "update PUBLIC.tbl1 as _T0 set VAL = ?, KEY = (_T0.KEY + ?) where (_T0.KEY > ?)", + "update PUBLIC.TBL1 as _T0 set VAL = ?, KEY = (_T0.KEY + ?) where (_T0.KEY > ?)", q => q.Where(x => x.Key > 3).ExecuteUpdateAsync( row => row .SetProperty(x => x.Key, x => x.Key + 1) diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Proto/ColocationHashTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Proto/ColocationHashTests.cs index 1496000e2bf..8abd58c4979 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/Proto/ColocationHashTests.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Proto/ColocationHashTests.cs @@ -166,7 +166,8 @@ public async Task TestCustomColocationColumnOrder([Values(true, false)] bool rev await Client.Sql.ExecuteAsync(null, sql); // Perform get to populate schema. - var table = await Client.Tables.GetTableAsync(tableName); + // TODO https://issues.apache.org/jira/browse/IGNITE-24258: Remove uppercase. + var table = await Client.Tables.GetTableAsync(tableName.ToUpperInvariant()); var view = table!.RecordBinaryView; await view.GetAsync(null, new IgniteTuple{["id"] = 1, ["id0"] = 2L, ["id1"] = "3"}); diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/KeyColumnOrderTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/KeyColumnOrderTests.cs index 23a178d2ff3..1566b69017b 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/KeyColumnOrderTests.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/KeyColumnOrderTests.cs @@ -26,7 +26,8 @@ namespace Apache.Ignite.Tests.Table; /// public class KeyColumnOrderTests : IgniteTestsBase { - private static readonly string[] Tables = { "test1", "test2", "test3", "test4" }; + // TODO https://issues.apache.org/jira/browse/IGNITE-24258: Revert changing names to uppercase. + private static readonly string[] Tables = { "TEST1", "TEST2", "TEST3", "TEST4" }; private int _key; diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/RecordViewPocoTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/RecordViewPocoTests.cs index 926c8390e2d..f4d00de97ee 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/RecordViewPocoTests.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/RecordViewPocoTests.cs @@ -572,7 +572,8 @@ public async Task TestBigPoco() using var deferDropTable = new DisposeAction( () => Client.Sql.ExecuteAsync(null, "DROP TABLE TestBigPoco").GetAwaiter().GetResult()); - var table = await Client.Tables.GetTableAsync("TestBigPoco"); + // TODO https://issues.apache.org/jira/browse/IGNITE-24258: Remove uppercase. + var table = await Client.Tables.GetTableAsync("TestBigPoco".ToUpperInvariant()); var pocoView = table!.GetRecordView(); var poco = new Poco2 diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/SchemaSynchronizationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/SchemaSynchronizationTest.cs index 44f1cbcf8b4..b7547a0f9f4 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/SchemaSynchronizationTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/SchemaSynchronizationTest.cs @@ -47,7 +47,8 @@ public enum TestMode private static string TestTableName => TestContext.CurrentContext.Test.Name .Replace("(", "_") .Replace(",", "_") - .Replace(")", string.Empty); + .Replace(")", string.Empty) + .ToUpperInvariant(); // TODO https://issues.apache.org/jira/browse/IGNITE-24258: Remove uppercase. [TearDown] public async Task DeleteTable() => await Client.Sql.ExecuteAsync(null, $"DROP TABLE {TestTableName}"); diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/SchemaValidationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/SchemaValidationTest.cs index e10e12dc385..5d9c5f76e89 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/SchemaValidationTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/SchemaValidationTest.cs @@ -39,7 +39,9 @@ public class SchemaValidationTest : IgniteTestsBase public async Task CreateTable() { await Client.Sql.ExecuteAsync(null, $"CREATE TABLE {TableNameRequiredVal} (KEY BIGINT PRIMARY KEY, VAL VARCHAR NOT NULL)"); - TableRequiredVal = (await Client.Tables.GetTableAsync(TableNameRequiredVal))!; + + // TODO https://issues.apache.org/jira/browse/IGNITE-24258: Remove uppercase. + TableRequiredVal = (await Client.Tables.GetTableAsync(TableNameRequiredVal.ToUpperInvariant()))!; } [OneTimeTearDown] diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TablesTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TablesTests.cs index 49a04ab7ec4..9c7749682ad 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TablesTests.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TablesTests.cs @@ -71,7 +71,8 @@ public async Task TestGetExistingTableReturnsSameInstanceEveryTime() [Test] public async Task TestGetNonExistentTableReturnsNull() { - var table = await Client.Tables.GetTableAsync(Guid.NewGuid().ToString()); + var tableName = Guid.NewGuid().ToString(); + var table = await Client.Tables.GetTableAsync($"\"{tableName}\""); Assert.IsNull(table); } diff --git a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerRestartPartitionsTest.java b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerRestartPartitionsTest.java index 1e84af87340..86414251fc7 100644 --- a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerRestartPartitionsTest.java +++ b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerRestartPartitionsTest.java @@ -43,7 +43,6 @@ import org.apache.ignite.internal.ClusterConfiguration; import org.apache.ignite.internal.ClusterPerClassIntegrationTest; import org.apache.ignite.internal.rest.api.recovery.RestartPartitionsRequest; -import org.apache.ignite.internal.util.StringUtils; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -88,7 +87,7 @@ public void testRestartPartitionZoneNotFound() { @Test public void testRestartPartitionTableNotFound() { - String tableName = canonicalName("PUBLIC", "unknown_table"); + String tableName = "PUBLIC.unknown_table"; MutableHttpRequest post = HttpRequest.POST(RESTART_PARTITIONS_ENDPOINT, new RestartPartitionsRequest(Set.of(), FIRST_ZONE, tableName, Set.of())); @@ -97,7 +96,7 @@ public void testRestartPartitionTableNotFound() { () -> client.toBlocking().exchange(post)); assertThat(e.getResponse().code(), is(BAD_REQUEST.code())); - assertThat(e.getMessage(), containsString("The table does not exist [name=" + StringUtils.escapeQuotes(tableName) + "]")); + assertThat(e.getMessage(), containsString("The table does not exist [name=" + tableName.toUpperCase() + "]")); } @Test diff --git a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerTest.java b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerTest.java index 92ebc2dc67d..5757cf565f6 100644 --- a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerTest.java +++ b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerTest.java @@ -25,7 +25,6 @@ import static org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_PARTITION_COUNT; import static org.apache.ignite.internal.rest.constants.HttpCode.BAD_REQUEST; import static org.apache.ignite.internal.sql.SqlCommon.DEFAULT_SCHEMA_NAME; -import static org.apache.ignite.internal.util.StringUtils.escapeQuotes; import static org.apache.ignite.lang.util.IgniteNameUtils.canonicalName; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -396,7 +395,7 @@ public void testResetPartitionZoneNotFound() { @Test public void testResetPartitionTableNotFound() { - String tableName = canonicalName("PUBLIC", "unknown_table"); + String tableName = "PUBLIC.unknown_table"; MutableHttpRequest post = HttpRequest.POST(RESET_PARTITIONS_ENDPOINT, new ResetPartitionsRequest(FIRST_ZONE, tableName, Set.of())); @@ -406,7 +405,7 @@ public void testResetPartitionTableNotFound() { assertThat(e.getResponse().code(), is(BAD_REQUEST.code())); - assertThat(e.getMessage(), containsString("The table does not exist [name=" + escapeQuotes(tableName) + "]")); + assertThat(e.getMessage(), containsString("The table does not exist [name=" + tableName.toUpperCase() + "]")); } @Test diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/inmemory/ItRaftStorageVolatilityTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/inmemory/ItRaftStorageVolatilityTest.java index 7e30244f426..01d4624e922 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/inmemory/ItRaftStorageVolatilityTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/inmemory/ItRaftStorageVolatilityTest.java @@ -49,6 +49,7 @@ import org.apache.ignite.internal.raft.util.SharedLogStorageFactoryUtils; import org.apache.ignite.internal.table.distributed.TableManager; import org.apache.ignite.internal.testframework.WithSystemProperty; +import org.apache.ignite.table.QualifiedName; import org.junit.jupiter.api.Test; import org.rocksdb.ColumnFamilyDescriptor; import org.rocksdb.ColumnFamilyHandle; @@ -109,7 +110,7 @@ private static String testTablePartitionPrefix(IgniteImpl ignite) { private static int testTableId(IgniteImpl ignite) { TableManager tables = unwrapTableManager(ignite.tables()); - return tables.tableView(TABLE_NAME).tableId(); + return tables.tableView(QualifiedName.fromSimple(TABLE_NAME)).tableId(); } @Test diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java index c21aa163229..185597a1d4f 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java @@ -1291,7 +1291,7 @@ private void assertTablePresent(TableManager tableManager, String tableName) { boolean isPresent = false; for (TableImpl table : tables) { - if (table.name().equals(tableName)) { + if (table.name().objectName().equals(tableName)) { isPresent = true; break; diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java index c943baca222..d869ec74dd0 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java @@ -57,7 +57,7 @@ void testThinClientConnectsToServerNodesAndExecutesBasicTableOperations() { assertEquals(1, tables.size()); Table table = tables.get(0); - assertEquals(TABLE_NAME, table.name()); + assertEquals(TABLE_NAME, table.name().objectName()); var tuple = Tuple.create().set(COLUMN_KEY, 1).set(COLUMN_VAL, "Hello"); var keyTuple = Tuple.create().set(COLUMN_KEY, 1); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaForwardCompatibilityTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaForwardCompatibilityTest.java index 1c63ed02f61..e23faefc0b2 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaForwardCompatibilityTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaForwardCompatibilityTest.java @@ -108,7 +108,7 @@ void forwardIncompatibleSchemaChangesDoNotAllowSyncCommit(ForwardIncompatibleDdl containsString(String.format( "Commit failed because schema is not forward-compatible [fromSchemaVersion=1, toSchemaVersion=2, table=%s, " + "details=%s]", - table.name(), + table.name().objectName(), ddl.expectedDetails )) ); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncSingleNodeTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncSingleNodeTest.java index 1f4297067d3..401d401b859 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncSingleNodeTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncSingleNodeTest.java @@ -108,7 +108,7 @@ void readWriteOperationInTxAfterAlteringSchemaOnTargetTableIsRejected(Operation ex.getMessage(), containsString(String.format( "Table schema was updated after the transaction was started [table=%s, startSchema=1, operationSchema=2]", - table.name() + table.name().objectName() )) ); } else { @@ -118,7 +118,7 @@ void readWriteOperationInTxAfterAlteringSchemaOnTargetTableIsRejected(Operation ex.getMessage(), is(String.format( "Table schema was updated after the transaction was started [table=%s, startSchema=1, operationSchema=2]", - table.name() + table.name().objectName() )) ); } @@ -146,7 +146,7 @@ private void enlistTableInTransaction(Table table, Transaction tx) { private static void executeRwReadOn(Table table, Transaction tx, int key, Cluster cluster) { cluster.doInSession(0, session -> { - executeUpdate("SELECT * FROM " + table.name() + " WHERE id = " + key, session, tx); + executeUpdate("SELECT * FROM " + table.name().toCanonicalForm() + " WHERE id = " + key, session, tx); }); } @@ -177,7 +177,7 @@ boolean sql() { @Override void execute(Table table, Transaction tx, Cluster cluster) { cluster.doInSession(0, session -> { - executeUpdate("UPDATE " + table.name() + " SET val = 'new value' WHERE id = " + KEY, session, tx); + executeUpdate("UPDATE " + table.name().toCanonicalForm() + " SET val = 'new value' WHERE id = " + KEY, session, tx); }); } @@ -297,7 +297,7 @@ void commitAfterDroppingTargetTableIsRejected(CommitOperation operation) { assertThat(ex, is(instanceOf(IncompatibleSchemaException.class))); assertThat( ex.getMessage(), - containsString(String.format("Commit failed because a table was already dropped [table=%s]", table.name())) + containsString(String.format("Commit failed because a table was already dropped [table=%s]", table.name().objectName())) ); assertThat(((IncompatibleSchemaException) ex).code(), is(Transactions.TX_INCOMPATIBLE_SCHEMA_ERR)); @@ -357,7 +357,7 @@ void readingDataInFutureVersionsFails(boolean scan) { containsString(String.format( "Operation failed because it tried to access a row with newer schema version than transaction's [table=%s, " + "txSchemaVersion=1, rowSchemaVersion=2]", - table.name() + table.name().objectName() )) ); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItColumnNameMappingTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItColumnNameMappingTest.java index 89a5f46799d..b27a38907fe 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItColumnNameMappingTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItColumnNameMappingTest.java @@ -48,7 +48,7 @@ public void createTables() { @BeforeEach public void clearTables() { for (Table t : CLUSTER.aliveNode().tables().tables()) { - sql("DELETE FROM " + t.name()); + sql("DELETE FROM " + t.name().toCanonicalForm()); } } diff --git a/modules/runner/src/main/java/org/apache/ignite/internal/restart/RestartProofIgniteTables.java b/modules/runner/src/main/java/org/apache/ignite/internal/restart/RestartProofIgniteTables.java index e9b53af26c8..1388db6b328 100644 --- a/modules/runner/src/main/java/org/apache/ignite/internal/restart/RestartProofIgniteTables.java +++ b/modules/runner/src/main/java/org/apache/ignite/internal/restart/RestartProofIgniteTables.java @@ -25,6 +25,7 @@ import org.apache.ignite.internal.wrapper.Wrapper; import org.apache.ignite.internal.wrapper.Wrappers; import org.apache.ignite.table.IgniteTables; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.Table; import org.jetbrains.annotations.Nullable; @@ -59,7 +60,7 @@ public CompletableFuture> tablesAsync() { } @Override - public Table table(String name) { + public Table table(QualifiedName name) { return attachmentLock.attached(ignite -> { Table table = ignite.tables().table(name); return wrapTable(table, ignite); @@ -67,7 +68,7 @@ public Table table(String name) { } @Override - public CompletableFuture

tableAsync(String name) { + public CompletableFuture
tableAsync(QualifiedName name) { return attachmentLock.attachedAsync(ignite -> ignite.tables().tableAsync(name) .thenApply(table -> wrapTable(table, ignite)) diff --git a/modules/runner/src/main/java/org/apache/ignite/internal/restart/RestartProofTable.java b/modules/runner/src/main/java/org/apache/ignite/internal/restart/RestartProofTable.java index 08053871208..0793af9fb75 100644 --- a/modules/runner/src/main/java/org/apache/ignite/internal/restart/RestartProofTable.java +++ b/modules/runner/src/main/java/org/apache/ignite/internal/restart/RestartProofTable.java @@ -23,6 +23,7 @@ import org.apache.ignite.internal.wrapper.Wrapper; import org.apache.ignite.internal.wrapper.Wrappers; import org.apache.ignite.table.KeyValueView; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.RecordView; import org.apache.ignite.table.Table; import org.apache.ignite.table.Tuple; @@ -70,7 +71,7 @@ private Table tableFromIgnite(Ignite ignite) { } @Override - public String name() { + public QualifiedName name() { return attachmentLock.attached(ignite -> tableCache.actualFor(ignite).name()); } diff --git a/modules/runner/src/testFixtures/java/org/apache/ignite/internal/ClusterPerClassIntegrationTest.java b/modules/runner/src/testFixtures/java/org/apache/ignite/internal/ClusterPerClassIntegrationTest.java index 242c928b2eb..a614047f0d3 100644 --- a/modules/runner/src/testFixtures/java/org/apache/ignite/internal/ClusterPerClassIntegrationTest.java +++ b/modules/runner/src/testFixtures/java/org/apache/ignite/internal/ClusterPerClassIntegrationTest.java @@ -22,11 +22,11 @@ import static org.apache.ignite.internal.TestDefaultProfilesNames.DEFAULT_ROCKSDB_PROFILE_NAME; import static org.apache.ignite.internal.TestDefaultProfilesNames.DEFAULT_TEST_PROFILE_NAME; import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl; -import static org.apache.ignite.internal.TestWrappers.unwrapTableImpl; import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_STORAGE_PROFILE; import static org.apache.ignite.internal.catalog.descriptors.CatalogIndexStatus.AVAILABLE; import static org.apache.ignite.internal.lang.IgniteStringFormatter.format; import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition; +import static org.apache.ignite.lang.util.IgniteNameUtils.quote; import static org.junit.jupiter.api.Assertions.assertTrue; import java.nio.file.Path; @@ -35,9 +35,7 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; -import java.util.Set; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.ignite.Ignite; import org.apache.ignite.InitParametersBuilder; @@ -46,24 +44,20 @@ import org.apache.ignite.internal.catalog.CatalogManager; import org.apache.ignite.internal.catalog.commands.CatalogUtils; import org.apache.ignite.internal.catalog.descriptors.CatalogIndexDescriptor; -import org.apache.ignite.internal.catalog.descriptors.CatalogSchemaDescriptor; -import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor; import org.apache.ignite.internal.catalog.descriptors.CatalogZoneDescriptor; import org.apache.ignite.internal.hlc.HybridClock; import org.apache.ignite.internal.lang.IgniteBiTuple; -import org.apache.ignite.internal.table.TableImpl; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; import org.apache.ignite.internal.testframework.TestIgnitionManager; import org.apache.ignite.internal.testframework.WorkDirectory; import org.apache.ignite.internal.testframework.WorkDirectoryExtension; -import org.apache.ignite.lang.util.IgniteNameUtils; import org.apache.ignite.network.ClusterNode; import org.apache.ignite.sql.IgniteSql; import org.apache.ignite.sql.ResultSet; import org.apache.ignite.sql.SqlRow; import org.apache.ignite.sql.Statement; import org.apache.ignite.sql.Statement.StatementBuilder; -import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.Table; import org.apache.ignite.tx.Transaction; import org.jetbrains.annotations.Nullable; @@ -144,7 +138,7 @@ protected int initialNodes() { } protected int[] cmgMetastoreNodes() { - return new int[] { 0 }; + return new int[]{0}; } protected boolean needInitializeCluster() { @@ -177,30 +171,8 @@ void stopCluster() { /** Drops all visible tables. */ protected static void dropAllTables() { - Ignite aliveNode = CLUSTER.aliveNode(); - - for (Table t : aliveNode.tables().tables()) { - IgniteImpl ignite = unwrapIgniteImpl(aliveNode); - CatalogManager catalogManager = ignite.catalogManager(); - - int latestCatalogVersion = catalogManager.latestCatalogVersion(); - Catalog latestCatalog = catalogManager.catalog(latestCatalogVersion); - assert latestCatalog != null; - - TableImpl tableImpl = unwrapTableImpl(t); - int tableId = tableImpl.tableId(); - - for (CatalogSchemaDescriptor schema : latestCatalog.schemas()) { - for (CatalogTableDescriptor table : schema.tables()) { - if (table.id() != tableId) { - continue; - } - String schemaName = IgniteNameUtils.quote(schema.name()); - String tableName = IgniteNameUtils.quote(table.name()); - - sql("DROP TABLE " + QualifiedName.of(schemaName, tableName).toCanonicalForm()); - } - } + for (Table t : CLUSTER.aliveNode().tables().tables()) { + sql("DROP TABLE " + t.name().toCanonicalForm()); } } @@ -210,24 +182,13 @@ protected static void dropAllSchemas() { IgniteImpl ignite = unwrapIgniteImpl(aliveNode); CatalogManager catalogManager = ignite.catalogManager(); - int latestCatalogVersion = catalogManager.latestCatalogVersion(); - Catalog latestCatalog = catalogManager.catalog(latestCatalogVersion); + Catalog latestCatalog = catalogManager.catalog(catalogManager.latestCatalogVersion()); assert latestCatalog != null; - Set quotedSystemSchemas = CatalogUtils.SYSTEM_SCHEMAS.stream() - .map(IgniteNameUtils::quote) - .collect(Collectors.toSet()); - - quotedSystemSchemas.add(IgniteNameUtils.quote(QualifiedName.DEFAULT_SCHEMA_NAME)); - - for (CatalogSchemaDescriptor schema : latestCatalog.schemas()) { - String schemaName = IgniteNameUtils.quote(schema.name()); - - if (quotedSystemSchemas.contains(schemaName)) { - continue; - } - sql("DROP SCHEMA " + schemaName + " CASCADE"); - } + latestCatalog.schemas().stream() + .filter(schema -> !CatalogUtils.SYSTEM_SCHEMAS.contains(schema.name())) + .filter(schema -> !SqlCommon.DEFAULT_SCHEMA_NAME.equals(schema.name())) + .forEach(schema -> sql("DROP SCHEMA " + quote(schema.name()) + " CASCADE")); } /** Drops all visible zones. */ @@ -535,7 +496,7 @@ public Person(int id, String name, double salary) { /** * Waits for some amount of time so that read-only transactions can observe the most recent version of the catalog. */ - protected static void waitForReadTimestampThatObservesMostRecentCatalog() { + protected static void waitForReadTimestampThatObservesMostRecentCatalog() { // See TxManagerImpl::currentReadTimestamp. long delay = TestIgnitionManager.DEFAULT_MAX_CLOCK_SKEW_MS + TestIgnitionManager.DEFAULT_PARTITION_IDLE_SYNC_TIME_INTERVAL_MS; @@ -556,7 +517,7 @@ protected static boolean isIndexAvailable(IgniteImpl ignite, String indexName) { CatalogManager catalogManager = ignite.catalogManager(); HybridClock clock = ignite.clock(); - CatalogIndexDescriptor indexDescriptor = catalogManager.aliveIndex(indexName, clock.nowLong()); + CatalogIndexDescriptor indexDescriptor = catalogManager.aliveIndex(SqlCommon.DEFAULT_SCHEMA_NAME, indexName, clock.nowLong()); return indexDescriptor != null && indexDescriptor.status() == AVAILABLE; } diff --git a/modules/runner/src/testFixtures/java/org/apache/ignite/internal/IndexTestUtils.java b/modules/runner/src/testFixtures/java/org/apache/ignite/internal/IndexTestUtils.java index 5ee6ce1ee61..6241f25704b 100644 --- a/modules/runner/src/testFixtures/java/org/apache/ignite/internal/IndexTestUtils.java +++ b/modules/runner/src/testFixtures/java/org/apache/ignite/internal/IndexTestUtils.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal; import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl; +import static org.apache.ignite.internal.sql.SqlCommon.DEFAULT_SCHEMA_NAME; import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -40,7 +41,7 @@ public static void waitForIndexToAppearInAnyState(String indexName, Ignite ignit IgniteImpl igniteImpl = unwrapIgniteImpl(ignite); assertTrue(waitForCondition( - () -> igniteImpl.catalogManager().aliveIndex(indexName, igniteImpl.clock().nowLong()) != null, + () -> igniteImpl.catalogManager().aliveIndex(DEFAULT_SCHEMA_NAME, indexName, igniteImpl.clock().nowLong()) != null, 10_000 )); } diff --git a/modules/spring/spring-boot-starter-ignite-client-example/src/test/java/org/apache/ignite/ExampleApplicationTest.java b/modules/spring/spring-boot-starter-ignite-client-example/src/test/java/org/apache/ignite/ExampleApplicationTest.java index ce10f5944db..1b3013f5bce 100644 --- a/modules/spring/spring-boot-starter-ignite-client-example/src/test/java/org/apache/ignite/ExampleApplicationTest.java +++ b/modules/spring/spring-boot-starter-ignite-client-example/src/test/java/org/apache/ignite/ExampleApplicationTest.java @@ -66,7 +66,7 @@ void test() { runner.run(null); }); - boolean tableExists = cluster.aliveNode().tables().tables().stream().anyMatch(t -> t.name().equals("PERSON")); + boolean tableExists = cluster.aliveNode().tables().tables().stream().anyMatch(t -> t.name().objectName().equals("PERSON")); ResultSet resultSet = cluster.aliveNode().sql().execute(null, "SELECT COUNT(*) FROM PERSON"); long rowsCount = resultSet.next().longValue(0); diff --git a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java index 990db0efebd..996715f90e4 100644 --- a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java +++ b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java @@ -404,7 +404,7 @@ public void tableStorageProfileWithoutSettingItExplicitly() { IgniteImpl node = unwrapIgniteImpl(CLUSTER.aliveNode()); - CatalogTableDescriptor table = node.catalogManager().table("TEST", node.clock().nowLong()); + CatalogTableDescriptor table = node.catalogManager().table(SCHEMA_NAME, "TEST", node.clock().nowLong()); CatalogZoneDescriptor zone = getDefaultZone(node); @@ -428,7 +428,7 @@ public void tableStorageProfile() { IgniteImpl node = unwrapIgniteImpl(CLUSTER.aliveNode()); - CatalogTableDescriptor table = node.catalogManager().table("TEST", node.clock().nowLong()); + CatalogTableDescriptor table = node.catalogManager().table(SCHEMA_NAME, "TEST", node.clock().nowLong()); assertEquals(DEFAULT_STORAGE_PROFILE, table.storageProfile()); @@ -445,7 +445,7 @@ public void tableStorageProfileWithCustomZoneDefaultProfile() { IgniteImpl node = unwrapIgniteImpl(CLUSTER.aliveNode()); - CatalogTableDescriptor table = node.catalogManager().table("TEST", node.clock().nowLong()); + CatalogTableDescriptor table = node.catalogManager().table(SCHEMA_NAME, "TEST", node.clock().nowLong()); assertEquals(DEFAULT_STORAGE_PROFILE, table.storageProfile()); @@ -462,7 +462,7 @@ public void tableStorageProfileWithCustomZoneExplicitProfile() { IgniteImpl node = unwrapIgniteImpl(CLUSTER.aliveNode()); - CatalogTableDescriptor table = node.catalogManager().table("TEST", node.clock().nowLong()); + CatalogTableDescriptor table = node.catalogManager().table(SCHEMA_NAME, "TEST", node.clock().nowLong()); assertEquals(DEFAULT_STORAGE_PROFILE, table.storageProfile()); diff --git a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItHashSpoolTest.java b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItHashSpoolTest.java index ef7a97c82fa..9721a0e6604 100644 --- a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItHashSpoolTest.java +++ b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItHashSpoolTest.java @@ -17,12 +17,8 @@ package org.apache.ignite.internal.sql.engine; -import org.apache.ignite.internal.ClusterPerClassIntegrationTest; -import org.apache.ignite.internal.logger.IgniteLogger; -import org.apache.ignite.internal.logger.Loggers; import org.apache.ignite.internal.sql.BaseSqlIntegrationTest; import org.apache.ignite.internal.sql.engine.util.QueryChecker; -import org.apache.ignite.table.Table; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -31,24 +27,12 @@ * Hash spool test. */ public class ItHashSpoolTest extends BaseSqlIntegrationTest { - private static final IgniteLogger LOG = Loggers.forClass(ClusterPerClassIntegrationTest.class); - /** * After each. */ @AfterEach protected void cleanUp() { - if (LOG.isInfoEnabled()) { - LOG.info("Start cleanUp()"); - } - - for (Table table : CLUSTER.aliveNode().tables().tables()) { - sql("DROP TABLE " + table.name()); - } - - if (LOG.isInfoEnabled()) { - LOG.info("End cleanUp()"); - } + dropAllTables(); } @Test diff --git a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItIndexSpoolTest.java b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItIndexSpoolTest.java index 52bbc4b5f93..36477716fbb 100644 --- a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItIndexSpoolTest.java +++ b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItIndexSpoolTest.java @@ -24,11 +24,7 @@ import java.util.List; import java.util.stream.Stream; -import org.apache.ignite.internal.ClusterPerClassIntegrationTest; -import org.apache.ignite.internal.logger.IgniteLogger; -import org.apache.ignite.internal.logger.Loggers; import org.apache.ignite.internal.sql.BaseSqlIntegrationTest; -import org.apache.ignite.table.Table; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; @@ -40,25 +36,13 @@ */ @Disabled("https://issues.apache.org/jira/browse/IGNITE-21286") public class ItIndexSpoolTest extends BaseSqlIntegrationTest { - private static final IgniteLogger LOG = Loggers.forClass(ClusterPerClassIntegrationTest.class); - /** * After each. */ @AfterEach protected void cleanUp() { - if (LOG.isInfoEnabled()) { - LOG.info("Start cleanUp()"); - } - - for (Table table : CLUSTER.aliveNode().tables().tables()) { - sql("DROP TABLE " + table.name()); - sql("DROP ZONE " + "ZONE_" + table.name().toUpperCase()); - } - - if (LOG.isInfoEnabled()) { - LOG.info("End cleanUp()"); - } + dropAllTables(); + dropAllZonesExceptDefaultOne(); } private static Stream rowsWithPartitionsArgs() { @@ -100,7 +84,7 @@ private void prepareDataSet(int rowsCount, int parts) { for (String name : List.of("TEST0", "TEST1")) { sql(String.format( "CREATE ZONE %s with replicas=2, partitions=%d, storage_profiles='%s'", - "ZONE_" + name.toUpperCase(), + "ZONE_" + name, parts, DEFAULT_STORAGE_PROFILE )); diff --git a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java index 03a36e785e4..9451831808b 100644 --- a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java +++ b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java @@ -238,7 +238,7 @@ public void testBinaryView(TestEnvironment env) { @ParameterizedTest @MethodSource("parameters") public void testSql(TestEnvironment env) { - String tableName = env.table().name(); + String tableName = env.table().name().toCanonicalForm(); env.runInTransaction( rwTx -> sql(rwTx, "insert into " + tableName + " values (0, 'A'), (1, 'B')"), @@ -259,7 +259,8 @@ public void testSql(TestEnvironment env) { public void testMixed(TestEnvironment env) { Table tab = env.table(); - String sqlInsert = "insert into " + tab.name() + " values (%d, '%s')"; + String tableName = tab.name().toCanonicalForm(); + String sqlInsert = "insert into " + tableName + " values (%d, '%s')"; String[] names = {"a", "b", "c", "d"}; RecordView recordView = tab.recordView(); @@ -315,12 +316,12 @@ public void testMixed(TestEnvironment env) { assertTrue(binView.contains(tx, key)); - assertQuery( - (InternalTransaction) tx, format("select * from {} where ID={} and NAME='{}'", tab.name(), i, names[i])) + String message = format("select * from {} where ID={} and NAME='{}'", tableName, i, names[i]); + assertQuery((InternalTransaction) tx, message) .returns(i, names[i]).check(); } - assertQuery((InternalTransaction) tx, "select count(*) from " + tab.name()).returns(4L).check(); + assertQuery((InternalTransaction) tx, "select count(*) from " + tableName).returns(4L).check(); } ); } @@ -350,7 +351,7 @@ private static List parameters() { } private static String tableName(String engineName) { - return "test_" + engineName; + return "\"test_" + engineName + '"'; } private static class KeyObject { diff --git a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTest.java b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTest.java index 49df7bca717..699a7b1fd8f 100644 --- a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTest.java +++ b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTest.java @@ -300,7 +300,7 @@ private void run(Path testPath) { private void beforeTest() { if (RESTART_CLUSTER != RestartMode.TEST) { for (Table t : CLUSTER_NODES.get(0).tables().tables()) { - try (ResultSet rs = CLUSTER_NODES.get(0).sql().execute(null, "DROP TABLE " + t.name())) { + try (ResultSet rs = CLUSTER_NODES.get(0).sql().execute(null, "DROP TABLE " + t.name().toCanonicalForm())) { assertTrue(rs.wasApplied()); } } diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ExecutableTableRegistrySelfTest.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ExecutableTableRegistrySelfTest.java index 5549817b357..281fc8377e0 100644 --- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ExecutableTableRegistrySelfTest.java +++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ExecutableTableRegistrySelfTest.java @@ -158,7 +158,7 @@ ExecutableTable getTable(int tableId) { when(descriptor.spliterator()).thenReturn(Spliterators.emptySpliterator()); IgniteTable sqlTable = new IgniteTableImpl( - table.name(), tableId, tableVersion, descriptor, ImmutableIntList.of(0), new TestStatistic(1_000.0), Map.of(), 1 + "TBL1", tableId, tableVersion, descriptor, ImmutableIntList.of(0), new TestStatistic(1_000.0), Map.of(), 1 ); when(sqlSchemaManager.table(schemaVersion, tableId)).thenReturn(sqlTable); diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/rel/TableScanNodeExecutionTest.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/rel/TableScanNodeExecutionTest.java index c7b780f271b..2b478f658a1 100644 --- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/rel/TableScanNodeExecutionTest.java +++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/rel/TableScanNodeExecutionTest.java @@ -61,6 +61,7 @@ import org.apache.ignite.internal.schema.BinaryRow; import org.apache.ignite.internal.schema.BinaryRowEx; import org.apache.ignite.internal.schema.BinaryTuplePrefix; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.sql.engine.exec.ExecutionContext; import org.apache.ignite.internal.sql.engine.exec.PartitionProvider; import org.apache.ignite.internal.sql.engine.exec.PartitionWithConsistencyToken; @@ -91,6 +92,7 @@ import org.apache.ignite.internal.type.NativeTypes; import org.apache.ignite.network.ClusterNode; import org.apache.ignite.network.NetworkAddress; +import org.apache.ignite.table.QualifiedNameHelper; import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -260,7 +262,7 @@ private static class TestInternalTableImpl extends InternalTableImpl { ClockService clockService ) { super( - "test", + QualifiedNameHelper.fromNormalized(SqlCommon.DEFAULT_SCHEMA_NAME, "test"), 1, PART_CNT, new SingleClusterNodeResolver(mock(ClusterNode.class)), diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/table/criteria/SqlSerializerIndexHintTest.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/table/criteria/SqlSerializerIndexHintTest.java index 3b4045ff52e..7816ef7b0c6 100644 --- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/table/criteria/SqlSerializerIndexHintTest.java +++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/table/criteria/SqlSerializerIndexHintTest.java @@ -19,6 +19,7 @@ import static org.apache.ignite.internal.lang.IgniteStringFormatter.format; import static org.apache.ignite.lang.util.IgniteNameUtils.quote; +import static org.apache.ignite.table.QualifiedName.fromSimple; import static org.apache.ignite.table.criteria.Criteria.and; import static org.apache.ignite.table.criteria.Criteria.columnValue; import static org.apache.ignite.table.criteria.Criteria.equalTo; @@ -46,17 +47,17 @@ class SqlSerializerIndexHintTest extends AbstractPlannerTest { @BeforeAll public static void setup() { - SCHEMA = AbstractPlannerTest.createSchemaFrom( + SCHEMA = createSchemaFrom( createSimpleTable(TBL1, 100) - .andThen(AbstractPlannerTest.addHashIndex("ID")) - .andThen(AbstractPlannerTest.addSortIndex("NAME")) + .andThen(addHashIndex("ID")) + .andThen(addSortIndex("NAME")) ); } @Test void testForceIndexHint() throws Exception { SqlSerializer ser = new SqlSerializer.Builder() - .tableName(TBL1) + .tableName(fromSimple(TBL1)) .indexName("idx_name") .columns(Set.of("ID", "NAME")) .where(and(columnValue("id", equalTo(1)), columnValue("name", equalTo("v")))) diff --git a/modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/BaseSqlIntegrationTest.java b/modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/BaseSqlIntegrationTest.java index 36ce4641916..75ae2846fda 100644 --- a/modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/BaseSqlIntegrationTest.java +++ b/modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/BaseSqlIntegrationTest.java @@ -59,6 +59,8 @@ */ @ExtendWith(QueryCheckerExtension.class) public abstract class BaseSqlIntegrationTest extends ClusterPerClassIntegrationTest { + protected static String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; + @InjectQueryCheckerFactory protected static QueryCheckerFactory queryCheckerFactory; diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java index 094fe03531e..ce0005316ca 100644 --- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java +++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java @@ -69,6 +69,7 @@ import org.apache.ignite.internal.schema.BinaryTuple; import org.apache.ignite.internal.schema.BinaryTupleSchema; import org.apache.ignite.internal.schema.BinaryTupleSchema.Element; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.storage.engine.MvPartitionMeta; import org.apache.ignite.internal.storage.engine.MvTableStorage; import org.apache.ignite.internal.storage.index.HashIndexStorage; @@ -304,7 +305,7 @@ public void indexDestructionDoesNotFailIfPartitionIsDestroyed(boolean waitForPar */ @Test public void testDestroySortedIndexIndependence() { - CatalogTableDescriptor catalogTableDescriptor = catalogService.table(TABLE_NAME, clock.nowLong()); + CatalogTableDescriptor catalogTableDescriptor = catalogService.table(SqlCommon.DEFAULT_SCHEMA_NAME, TABLE_NAME, clock.nowLong()); assertThat(catalogTableDescriptor, is(notNullValue())); var catalogSortedIndex1 = new CatalogSortedIndexDescriptor( @@ -358,7 +359,7 @@ public void testDestroySortedIndexIndependence() { */ @Test public void testDestroyHashIndexIndependence() { - CatalogTableDescriptor catalogTableDescriptor = catalogService.table(TABLE_NAME, clock.nowLong()); + CatalogTableDescriptor catalogTableDescriptor = catalogService.table(SqlCommon.DEFAULT_SCHEMA_NAME, TABLE_NAME, clock.nowLong()); assertThat(catalogTableDescriptor, is(notNullValue())); var catalogHashIndex1 = new CatalogHashIndexDescriptor( diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/BaseMvTableStorageTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/BaseMvTableStorageTest.java index 6a49ec1cba1..5ce2733ab5d 100644 --- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/BaseMvTableStorageTest.java +++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/BaseMvTableStorageTest.java @@ -45,6 +45,7 @@ import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor; import org.apache.ignite.internal.hlc.HybridTimestamp; import org.apache.ignite.internal.schema.BinaryRow; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.storage.engine.MvTableStorage; import org.apache.ignite.internal.storage.index.IndexStorage; import org.apache.ignite.internal.storage.index.StorageHashIndexDescriptor; @@ -60,6 +61,8 @@ */ @SuppressWarnings("JUnitTestMethodInProductSource") public abstract class BaseMvTableStorageTest extends BaseMvStoragesTest { + protected static final String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; + protected static final String TABLE_NAME = "FOO"; protected static final String PK_INDEX_NAME = pkIndexName(TABLE_NAME); @@ -191,10 +194,10 @@ private static void createTestTableAndIndexes(CatalogService catalogService) { true ); - when(catalogService.table(eq(TABLE_NAME), anyLong())).thenReturn(tableDescriptor); - when(catalogService.aliveIndex(eq(SORTED_INDEX_NAME), anyLong())).thenReturn(sortedIndex); - when(catalogService.aliveIndex(eq(HASH_INDEX_NAME), anyLong())).thenReturn(hashIndex); - when(catalogService.aliveIndex(eq(PK_INDEX_NAME), anyLong())).thenReturn(pkIndex); + when(catalogService.table(eq(SCHEMA_NAME), eq(TABLE_NAME), anyLong())).thenReturn(tableDescriptor); + when(catalogService.aliveIndex(eq(SCHEMA_NAME), eq(SORTED_INDEX_NAME), anyLong())).thenReturn(sortedIndex); + when(catalogService.aliveIndex(eq(SCHEMA_NAME), eq(HASH_INDEX_NAME), anyLong())).thenReturn(hashIndex); + when(catalogService.aliveIndex(eq(SCHEMA_NAME), eq(PK_INDEX_NAME), anyLong())).thenReturn(pkIndex); when(catalogService.table(eq(tableId), anyInt())).thenReturn(tableDescriptor); when(catalogService.index(eq(sortedIndexId), anyInt())).thenReturn(sortedIndex); @@ -218,12 +221,12 @@ protected final void initialize() { this.tableStorage = createMvTableStorage(); - CatalogTableDescriptor catalogTableDescriptor = catalogService.table(TABLE_NAME, clock.nowLong()); + CatalogTableDescriptor catalogTableDescriptor = catalogService.table(SqlCommon.DEFAULT_SCHEMA_NAME, TABLE_NAME, clock.nowLong()); assertNotNull(catalogTableDescriptor); - CatalogIndexDescriptor catalogSortedIndexDescriptor = catalogService.aliveIndex(SORTED_INDEX_NAME, clock.nowLong()); - CatalogIndexDescriptor catalogHashIndexDescriptor = catalogService.aliveIndex(HASH_INDEX_NAME, clock.nowLong()); - CatalogIndexDescriptor catalogPkIndexDescriptor = catalogService.aliveIndex(PK_INDEX_NAME, clock.nowLong()); + CatalogIndexDescriptor catalogSortedIndexDescriptor = catalogService.aliveIndex(SCHEMA_NAME, SORTED_INDEX_NAME, clock.nowLong()); + CatalogIndexDescriptor catalogHashIndexDescriptor = catalogService.aliveIndex(SCHEMA_NAME, HASH_INDEX_NAME, clock.nowLong()); + CatalogIndexDescriptor catalogPkIndexDescriptor = catalogService.aliveIndex(SCHEMA_NAME, PK_INDEX_NAME, clock.nowLong()); assertNotNull(catalogSortedIndexDescriptor); assertNotNull(catalogHashIndexDescriptor); diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractHashIndexStorageTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractHashIndexStorageTest.java index 179c5881768..b1cf1c23d8a 100644 --- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractHashIndexStorageTest.java +++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractHashIndexStorageTest.java @@ -41,7 +41,7 @@ public abstract class AbstractHashIndexStorageTest extends AbstractIndexStorageTest { @Override protected HashIndexStorage createIndexStorage(String name, boolean built, ColumnType... columnTypes) { - CatalogTableDescriptor tableDescriptor = catalogService.table(TABLE_NAME, clock.nowLong()); + CatalogTableDescriptor tableDescriptor = catalogService.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong()); int tableId = tableDescriptor.id(); int indexId = catalogId.getAndIncrement(); diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractIndexStorageTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractIndexStorageTest.java index c9ab8295ce3..1027d9d8601 100644 --- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractIndexStorageTest.java +++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractIndexStorageTest.java @@ -59,6 +59,7 @@ import org.apache.ignite.internal.hlc.HybridClock; import org.apache.ignite.internal.hlc.HybridClockImpl; import org.apache.ignite.internal.schema.BinaryTuple; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.storage.MvPartitionStorage; import org.apache.ignite.internal.storage.RowId; import org.apache.ignite.internal.storage.TestStorageUtils; @@ -87,6 +88,8 @@ public abstract class AbstractIndexStorageTest * @see #completeBuildIndex(IndexStorage) */ protected SortedIndexStorage createIndexStorage(String name, boolean built, CatalogIndexColumnDescriptor... columns) { - CatalogTableDescriptor tableDescriptor = catalogService.table(TABLE_NAME, clock.nowLong()); + CatalogTableDescriptor tableDescriptor = catalogService.table(SCHEMA_NAME, TABLE_NAME, clock.nowLong()); int tableId = tableDescriptor.id(); int indexId = catalogId.getAndIncrement(); diff --git a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItColocationTest.java b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItColocationTest.java index f6fcefd9e79..0b5bf7adc33 100644 --- a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItColocationTest.java +++ b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItColocationTest.java @@ -94,6 +94,7 @@ import org.apache.ignite.internal.schema.SchemaRegistry; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.sql.engine.util.SqlTestUtils; import org.apache.ignite.internal.storage.engine.MvTableStorage; import org.apache.ignite.internal.table.distributed.schema.ConstantSchemaVersions; @@ -121,6 +122,7 @@ import org.apache.ignite.internal.util.CollectionUtils; import org.apache.ignite.network.ClusterNode; import org.apache.ignite.sql.IgniteSql; +import org.apache.ignite.table.QualifiedNameHelper; import org.apache.ignite.table.Tuple; import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.AfterAll; @@ -334,7 +336,7 @@ public NetworkMessage clone() { })); intTable = new InternalTableImpl( - "PUBLIC.TEST", + QualifiedNameHelper.fromNormalized(SqlCommon.DEFAULT_SCHEMA_NAME, "TEST"), tblId, PARTS, new SingleClusterNodeResolver(clusterNode), diff --git a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/AbstractHighAvailablePartitionsRecoveryTest.java b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/AbstractHighAvailablePartitionsRecoveryTest.java index 7ffbc66bc84..14be562d3d2 100644 --- a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/AbstractHighAvailablePartitionsRecoveryTest.java +++ b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/AbstractHighAvailablePartitionsRecoveryTest.java @@ -54,6 +54,7 @@ import org.apache.ignite.internal.metastorage.Entry; import org.apache.ignite.internal.partitiondistribution.Assignment; import org.apache.ignite.internal.replicator.TablePartitionId; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.versioned.VersionedSerialization; /** Parent for tests of HA zones feature. */ @@ -86,7 +87,7 @@ private void assertRecoveryRequestForZoneTable(IgniteImpl node, String zoneName, recoveryTriggerEntry.value(), DisasterRecoveryRequestSerializer.INSTANCE); int zoneId = node.catalogManager().zone(zoneName, clock.nowLong()).id(); - int tableId = node.catalogManager().table(tableName, clock.nowLong()).id(); + int tableId = node.catalogManager().table(SqlCommon.DEFAULT_SCHEMA_NAME, tableName, clock.nowLong()).id(); assertEquals(zoneId, request.zoneId()); assertEquals(Map.of(tableId, PARTITION_IDS), request.partitionIds()); diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java b/modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java index 416e3bc190f..8dd60c72a59 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java @@ -21,6 +21,7 @@ import org.apache.ignite.internal.lang.NodeStoppingException; import org.apache.ignite.lang.IgniteException; import org.apache.ignite.table.IgniteTables; +import org.apache.ignite.table.QualifiedName; import org.jetbrains.annotations.Nullable; /** @@ -59,7 +60,7 @@ public interface IgniteTablesInternal extends IgniteTables { *
  • the node is stopping.
  • * */ - TableViewInternal tableView(String name); + TableViewInternal tableView(QualifiedName name); /** * Gets a table by name, if it was created before. @@ -73,7 +74,7 @@ public interface IgniteTablesInternal extends IgniteTables { *
  • the node is stopping.
  • * */ - CompletableFuture tableViewAsync(String name); + CompletableFuture tableViewAsync(QualifiedName name); /** * Returns a cached table instance if it exists, {@code null} otherwise. Can return a table that is being stopped. diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/InternalTable.java b/modules/table/src/main/java/org/apache/ignite/internal/table/InternalTable.java index 600b3edcd0f..52a4367d41b 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/InternalTable.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/InternalTable.java @@ -38,6 +38,7 @@ import org.apache.ignite.internal.util.PendingComparableValuesTracker; import org.apache.ignite.internal.utils.PrimaryReplica; import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.tx.TransactionException; import org.jetbrains.annotations.Nullable; @@ -65,7 +66,7 @@ public interface InternalTable extends ManuallyCloseable { * * @return Table name. */ - String name(); + QualifiedName name(); /** * Sets the name of the table. diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java index 7b858903efa..93d69384d83 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java @@ -47,6 +47,7 @@ import org.apache.ignite.internal.tx.LockManager; import org.apache.ignite.sql.IgniteSql; import org.apache.ignite.table.KeyValueView; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.RecordView; import org.apache.ignite.table.Tuple; import org.apache.ignite.table.mapper.Mapper; @@ -148,7 +149,7 @@ public PartitionManager partitionManager() { return new HashPartitionManagerImpl(tbl, schemaReg, marshallers); } - @Override public String name() { + @Override public QualifiedName name() { return tbl.name(); } @@ -164,9 +165,7 @@ public SchemaRegistry schemaView() { @Override public void schemaView(SchemaRegistry schemaReg) { - assert this.schemaReg == null : "Schema registry is already set [tableName=" + name() + ']'; - - Objects.requireNonNull(schemaReg, "Schema registry must not be null [tableName=" + name() + ']'); + Objects.requireNonNull(schemaReg, () -> "Schema registry must not be null [tableName=" + name().toCanonicalForm() + ']'); this.schemaReg = schemaReg; } diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/PublicApiThreadingIgniteTables.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/PublicApiThreadingIgniteTables.java index cd3e3d4e6e9..81b5cbd6978 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/PublicApiThreadingIgniteTables.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/PublicApiThreadingIgniteTables.java @@ -25,6 +25,7 @@ import org.apache.ignite.internal.thread.PublicApiThreading; import org.apache.ignite.internal.wrapper.Wrapper; import org.apache.ignite.table.IgniteTables; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.Table; import org.jetbrains.annotations.Nullable; @@ -73,12 +74,12 @@ public CompletableFuture> tablesAsync() { } @Override - public Table table(String name) { + public Table table(QualifiedName name) { return applyAntiHijackProtection(tables.table(name)); } @Override - public CompletableFuture
    tableAsync(String name) { + public CompletableFuture
    tableAsync(QualifiedName name) { return preventThreadHijack(tables.tableAsync(name)) .thenApply(this::applyAntiHijackProtection); } diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/PublicApiThreadingTable.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/PublicApiThreadingTable.java index a0943a32e45..483b9bfac6f 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/PublicApiThreadingTable.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/PublicApiThreadingTable.java @@ -25,6 +25,7 @@ import org.apache.ignite.internal.thread.PublicApiThreading; import org.apache.ignite.internal.wrapper.Wrapper; import org.apache.ignite.table.KeyValueView; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.RecordView; import org.apache.ignite.table.Table; import org.apache.ignite.table.Tuple; @@ -51,7 +52,7 @@ public PublicApiThreadingTable(Table table, Executor asyncContinuationExecutor) } @Override - public String name() { + public QualifiedName name() { return table.name(); } diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java index aa3708006a2..e650998c5fc 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java @@ -101,6 +101,7 @@ import java.util.stream.Stream; import org.apache.ignite.internal.catalog.Catalog; import org.apache.ignite.internal.catalog.CatalogService; +import org.apache.ignite.internal.catalog.descriptors.CatalogSchemaDescriptor; import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor; import org.apache.ignite.internal.catalog.descriptors.CatalogZoneDescriptor; import org.apache.ignite.internal.catalog.descriptors.ConsistencyMode; @@ -237,9 +238,10 @@ import org.apache.ignite.internal.utils.RebalanceUtilEx; import org.apache.ignite.internal.worker.ThreadAssertions; import org.apache.ignite.lang.IgniteException; -import org.apache.ignite.lang.util.IgniteNameUtils; import org.apache.ignite.network.ClusterNode; import org.apache.ignite.sql.IgniteSql; +import org.apache.ignite.table.QualifiedName; +import org.apache.ignite.table.QualifiedNameHelper; import org.apache.ignite.table.Table; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -763,17 +765,19 @@ private CompletableFuture prepareTableResourcesAndLoadToZoneReplica(Cre long causalityToken = parameters.causalityToken(); CatalogTableDescriptor tableDescriptor = parameters.tableDescriptor(); CatalogZoneDescriptor zoneDescriptor = getZoneDescriptor(tableDescriptor, parameters.catalogVersion()); + CatalogSchemaDescriptor schemaDescriptor = getSchemaDescriptor(tableDescriptor, parameters.catalogVersion()); - return prepareTableResourcesAndLoadToZoneReplica(causalityToken, zoneDescriptor, tableDescriptor, false); + return prepareTableResourcesAndLoadToZoneReplica(causalityToken, zoneDescriptor, tableDescriptor, schemaDescriptor, false); } private CompletableFuture prepareTableResourcesAndLoadToZoneReplica( long causalityToken, CatalogZoneDescriptor zoneDescriptor, CatalogTableDescriptor tableDescriptor, + CatalogSchemaDescriptor schemaDescriptor, boolean onNodeRecovery ) { - TableImpl table = createTableImpl(causalityToken, tableDescriptor, zoneDescriptor); + TableImpl table = createTableImpl(causalityToken, tableDescriptor, zoneDescriptor, schemaDescriptor); int tableId = tableDescriptor.id(); @@ -1588,7 +1592,7 @@ private CompletableFuture tableStopFuture(TableImpl table) { }, ioExecutor) .whenComplete((res, ex) -> { if (ex != null) { - LOG.error("Unable to stop table [name={}, tableId={}]", ex, table.name(), table.tableId()); + LOG.error("Unable to stop table [name={}, tableId={}]", ex, table.name().toCanonicalForm(), table.tableId()); } }); } @@ -1599,16 +1603,18 @@ private CompletableFuture tableStopFuture(TableImpl table) { * @param causalityToken Causality token. * @param tableDescriptor Catalog table descriptor. * @param zoneDescriptor Catalog distribution zone descriptor. + * @param schemaDescriptor Catalog schema descriptor. * @return Table instance. */ private TableImpl createTableImpl( long causalityToken, CatalogTableDescriptor tableDescriptor, - CatalogZoneDescriptor zoneDescriptor + CatalogZoneDescriptor zoneDescriptor, + CatalogSchemaDescriptor schemaDescriptor ) { - String tableName = tableDescriptor.name(); + QualifiedName tableName = QualifiedNameHelper.fromNormalized(schemaDescriptor.name(), tableDescriptor.name()); - LOG.trace("Creating local table: name={}, id={}, token={}", tableDescriptor.name(), tableDescriptor.id(), causalityToken); + LOG.trace("Creating local table: name={}, id={}, token={}", tableName.toCanonicalForm(), tableDescriptor.id(), causalityToken); MvTableStorage tableStorage = createTableStorage(tableDescriptor, zoneDescriptor); TxStateTableStorage txStateStorage = createTxStateTableStorage(tableDescriptor, zoneDescriptor); @@ -1665,6 +1671,7 @@ private CompletableFuture createTableLocally( // Retrieve descriptor during synchronous call, before the previous catalog version could be concurrently compacted. CatalogZoneDescriptor zoneDescriptor = getZoneDescriptor(tableDescriptor, catalogVersion); + CatalogSchemaDescriptor schemaDescriptor = getSchemaDescriptor(tableDescriptor, catalogVersion); // Returns stable assignments. CompletableFuture> stableAssignmentsFuture = getOrCreateAssignments( @@ -1689,6 +1696,7 @@ private CompletableFuture createTableLocally( causalityToken, tableDescriptor, zoneDescriptor, + schemaDescriptor, stableAssignmentsFutureAfterInvoke, pendingAssignments, assignmentsChains, @@ -1704,6 +1712,7 @@ private CompletableFuture createTableLocally( * @param causalityToken Causality token. * @param tableDescriptor Catalog table descriptor. * @param zoneDescriptor Catalog distributed zone descriptor. + * @param schemaDescriptor Catalog schema descriptor. * @param stableAssignmentsFuture Future with assignments. * @param onNodeRecovery {@code true} when called during node recovery, {@code false} otherwise. * @return Future that will be completed when local changes related to the table creation are applied. @@ -1712,13 +1721,14 @@ private CompletableFuture createTableLocally( long causalityToken, CatalogTableDescriptor tableDescriptor, CatalogZoneDescriptor zoneDescriptor, + CatalogSchemaDescriptor schemaDescriptor, CompletableFuture> stableAssignmentsFuture, List pendingAssignments, List assignmentsChains, boolean onNodeRecovery, long assignmentsTimestamp ) { - TableImpl table = createTableImpl(causalityToken, tableDescriptor, zoneDescriptor); + TableImpl table = createTableImpl(causalityToken, tableDescriptor, zoneDescriptor, schemaDescriptor); int tableId = tableDescriptor.id(); @@ -1973,7 +1983,7 @@ public Map startedTables() { } @Override - public Table table(String name) { + public Table table(QualifiedName name) { return join(tableAsync(name)); } @@ -1983,8 +1993,8 @@ public TableViewInternal table(int id) throws NodeStoppingException { } @Override - public CompletableFuture
    tableAsync(String name) { - return tableAsyncInternal(IgniteNameUtils.parseSimpleName(name)) + public CompletableFuture
    tableAsync(QualifiedName name) { + return tableAsyncInternal(name) .thenApply(identity()); } @@ -2037,13 +2047,13 @@ public CompletableFuture localPartitionSetAsync(long causalityToke } @Override - public TableViewInternal tableView(String name) { + public TableViewInternal tableView(QualifiedName name) { return join(tableViewAsync(name)); } @Override - public CompletableFuture tableViewAsync(String name) { - return tableAsyncInternal(IgniteNameUtils.parseSimpleName(name)); + public CompletableFuture tableViewAsync(QualifiedName name) { + return tableAsyncInternal(name); } /** @@ -2052,13 +2062,14 @@ public CompletableFuture tableViewAsync(String name) { * @param name Table name. * @return Future representing pending completion of the {@code TableManager#tableAsyncInternal} operation. */ - private CompletableFuture tableAsyncInternal(String name) { + private CompletableFuture tableAsyncInternal(QualifiedName name) { return inBusyLockAsync(busyLock, () -> { HybridTimestamp now = clockService.now(); return orStopManagerFuture(executorInclinedSchemaSyncService.waitForMetadataCompleteness(now)) .thenCompose(unused -> inBusyLockAsync(busyLock, () -> { - CatalogTableDescriptor tableDescriptor = catalogService.table(name, now.longValue()); + CatalogTableDescriptor tableDescriptor = catalogService.table(name.schemaName(), name.objectName(), + now.longValue()); // Check if the table has been deleted. if (tableDescriptor == null) { @@ -2205,7 +2216,7 @@ private CompletableFuture handleChangePendingAssignmentEvent( + "partition={}, table={}, localMemberAddress={}, pendingAssignments={}, revision={}]", stringKey, replicaGrpId.partitionId(), - table.name(), + table.name().toCanonicalForm(), localNode().address(), pendingAssignments, revision @@ -2890,8 +2901,17 @@ private CatalogZoneDescriptor getZoneDescriptor(CatalogTableDescriptor tableDesc return zoneDescriptor; } + private CatalogSchemaDescriptor getSchemaDescriptor(CatalogTableDescriptor tableDescriptor, int catalogVersion) { + CatalogSchemaDescriptor schemaDescriptor = catalogService.schema(tableDescriptor.schemaId(), catalogVersion); + + assert schemaDescriptor != null : + "tableId=" + tableDescriptor.id() + ", schemaId=" + tableDescriptor.schemaId() + ", catalogVersion=" + catalogVersion; + + return schemaDescriptor; + } + private static @Nullable TableImpl findTableImplByName(Collection tables, String name) { - return tables.stream().filter(table -> table.name().equals(name)).findAny().orElse(null); + return tables.stream().filter(table -> table.name().equals(QualifiedName.fromSimple(name))).findAny().orElse(null); } private void startTables(long recoveryRevision, @Nullable HybridTimestamp lwm) { @@ -2908,12 +2928,14 @@ private void startTables(long recoveryRevision, @Nullable HybridTimestamp lwm) { .forEach(tableDescriptor -> { if (PartitionReplicaLifecycleManager.ENABLED) { CatalogZoneDescriptor zoneDescriptor = getZoneDescriptor(tableDescriptor, ver0); + CatalogSchemaDescriptor schemaDescriptor = getSchemaDescriptor(tableDescriptor, ver0); startTableFutures.add( prepareTableResourcesAndLoadToZoneReplica( recoveryRevision, zoneDescriptor, tableDescriptor, + schemaDescriptor, true ) ); diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/disaster/DisasterRecoveryManager.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/disaster/DisasterRecoveryManager.java index 7daaacd3f7a..2785b6b3dac 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/disaster/DisasterRecoveryManager.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/disaster/DisasterRecoveryManager.java @@ -112,6 +112,7 @@ import org.apache.ignite.internal.versioned.VersionedSerialization; import org.apache.ignite.lang.TableNotFoundException; import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.table.QualifiedNameHelper; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -996,7 +997,7 @@ private static CatalogTableDescriptor tableDescriptor(Catalog catalog, String sc CatalogTableDescriptor tableDescriptor = catalog.table(schemaName, tableName); if (tableDescriptor == null) { - throw new TableNotFoundException(schemaName, tableName); + throw new TableNotFoundException(QualifiedNameHelper.fromNormalized(schemaName, tableName)); } return tableDescriptor; diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java index e7dc54e8008..bea58242518 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java @@ -131,6 +131,8 @@ import org.apache.ignite.internal.utils.PrimaryReplica; import org.apache.ignite.lang.IgniteException; import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.table.QualifiedName; +import org.apache.ignite.table.QualifiedNameHelper; import org.apache.ignite.tx.TransactionException; import org.jetbrains.annotations.Nullable; @@ -159,7 +161,7 @@ public class InternalTableImpl implements InternalTable { private final StreamerReceiverRunner streamerReceiverRunner; /** Table name. */ - private volatile String tableName; + private volatile QualifiedName tableName; /** Table identifier. */ private final int tableId; @@ -223,7 +225,7 @@ public class InternalTableImpl implements InternalTable { * @param attemptsObtainLock Attempts to take lock. */ public InternalTableImpl( - String tableName, + QualifiedName tableName, int tableId, int partitions, ClusterNodeResolver clusterNodeResolver, @@ -278,13 +280,13 @@ public int tableId() { /** {@inheritDoc} */ @Override - public String name() { + public QualifiedName name() { return tableName; } @Override - public void name(String newName) { - this.tableName = newName; + public synchronized void name(String newName) { + this.tableName = QualifiedNameHelper.fromNormalized(tableName.schemaName(), newName); } /** @@ -818,9 +820,10 @@ private CompletableFuture sendReadOnlyToPrimaryReplica( return replicaSvc.invoke(node, op.apply(tablePartitionId, enlistmentConsistencyToken(primaryReplica))); } catch (Throwable e) { + String canonicalName = tableName.toCanonicalForm(); throw new TransactionException( INTERNAL_ERR, - format("Failed to invoke the replica request [tableName={}, grp={}].", tableName, tablePartitionId), + format("Failed to invoke the replica request [tableName={}, grp={}].", canonicalName, tablePartitionId), e ); } diff --git a/modules/table/src/main/java/org/apache/ignite/table/TupleHelper.java b/modules/table/src/main/java/org/apache/ignite/table/TupleHelper.java index 73eece77497..9b4d25f5dfa 100644 --- a/modules/table/src/main/java/org/apache/ignite/table/TupleHelper.java +++ b/modules/table/src/main/java/org/apache/ignite/table/TupleHelper.java @@ -23,7 +23,7 @@ /** * Utility class to provide direct access to internals of {@link TupleImpl}. */ -public class TupleHelper { +public final class TupleHelper { /** * Returns value from a given tuple which corresponds to a specified column. * @@ -44,4 +44,8 @@ public class TupleHelper { return tuple.valueOrDefault(IgniteNameUtils.quote(normalizedName), defaultValue); } + + private TupleHelper() { + // No-op. + } } diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/CatalogStorageIndexDescriptorSupplierTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/CatalogStorageIndexDescriptorSupplierTest.java index 611067c1d13..840d6d2c980 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/CatalogStorageIndexDescriptorSupplierTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/CatalogStorageIndexDescriptorSupplierTest.java @@ -66,6 +66,8 @@ class CatalogStorageIndexDescriptorSupplierTest extends BaseIgniteAbstractTest { private static final long MIN_DATA_AVAILABILITY_TIME = DEFAULT_IDLE_SAFE_TIME_PROPAGATION_PERIOD_MILLISECONDS + TEST_MAX_CLOCK_SKEW_MILLIS; + private static final String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; + private static final String TABLE_NAME = "TEST"; private static final String INDEX_NAME = "TEST_IDX"; @@ -123,7 +125,7 @@ void testGetDroppedIndex() { int indexId = createIndex(); CatalogCommand dropIndexCommand = DropIndexCommand.builder() - .schemaName(SqlCommon.DEFAULT_SCHEMA_NAME) + .schemaName(SCHEMA_NAME) .indexName(INDEX_NAME) .build(); @@ -161,7 +163,7 @@ void testGetDroppedIndexAfterWatermark() throws InterruptedException { int indexId = createIndex(); CatalogCommand dropIndexCommand = DropIndexCommand.builder() - .schemaName(SqlCommon.DEFAULT_SCHEMA_NAME) + .schemaName(SCHEMA_NAME) .indexName(INDEX_NAME) .build(); @@ -188,13 +190,13 @@ private int createIndex() { List commands = List.of( CreateTableCommand.builder() - .schemaName(SqlCommon.DEFAULT_SCHEMA_NAME) + .schemaName(SCHEMA_NAME) .tableName(TABLE_NAME) .columns(List.of(ColumnParams.builder().name("foo").type(ColumnType.INT32).build())) .primaryKey(primaryKey) .build(), CreateHashIndexCommand.builder() - .schemaName(SqlCommon.DEFAULT_SCHEMA_NAME) + .schemaName(SCHEMA_NAME) .tableName(TABLE_NAME) .indexName(INDEX_NAME) .columns(List.of("foo")) @@ -203,7 +205,7 @@ private int createIndex() { assertThat(catalogManager.execute(commands), willCompleteSuccessfully()); - CatalogIndexDescriptor index = catalogManager.aliveIndex(INDEX_NAME, clock.nowLong()); + CatalogIndexDescriptor index = catalogManager.aliveIndex(SCHEMA_NAME, INDEX_NAME, clock.nowLong()); assertThat(index, is(notNullValue())); diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerRecoveryTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerRecoveryTest.java index c5045d5762f..bdd7eb57cd5 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerRecoveryTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerRecoveryTest.java @@ -151,6 +151,7 @@ public class TableManagerRecoveryTest extends IgniteAbstractTest { private static final String NODE_NAME = "testNode1"; private static final String ZONE_NAME = "zone1"; + private static final String SCHEMA_NAME = SqlCommon.DEFAULT_SCHEMA_NAME; private static final String TABLE_NAME = "testTable"; private static final String INDEX_NAME = "testIndex1"; private static final String INDEXED_COLUMN_NAME = "columnName"; @@ -243,7 +244,7 @@ public void testTableStartedOnRecovery() throws Exception { createTable(TABLE_NAME); createIndex(TABLE_NAME, INDEX_NAME); - int tableId = catalogManager.table(TABLE_NAME, Long.MAX_VALUE).id(); + int tableId = catalogManager.table(SCHEMA_NAME, TABLE_NAME, Long.MAX_VALUE).id(); verify(mvTableStorage, timeout(WAIT_TIMEOUT).times(PARTITIONS)).createMvPartition(anyInt()); verify(txStateTableStorage, timeout(WAIT_TIMEOUT).times(PARTITIONS)).getOrCreateTxStateStorage(anyInt()); diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java index 7f692452ca9..fcec645d82e 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java @@ -147,6 +147,7 @@ import org.apache.ignite.network.ClusterNode; import org.apache.ignite.network.NetworkAddress; import org.apache.ignite.sql.IgniteSql; +import org.apache.ignite.table.QualifiedName; import org.apache.ignite.table.Table; import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.AfterEach; @@ -468,7 +469,7 @@ public void testReCreateTableWithSameName() throws Exception { dropTable(DYNAMIC_TABLE_NAME); createTable(DYNAMIC_TABLE_NAME); - table = tableManager.tableView(DYNAMIC_TABLE_NAME); + table = tableManager.tableView(table.name()); assertNotNull(table); assertNotEquals(oldTableId, table.tableId()); @@ -789,7 +790,7 @@ private TableViewInternal mockManagersAndCreateTableWithDelay( createTable(tableName); - TableViewInternal tbl2 = tableManager.tableView(tableName); + TableViewInternal tbl2 = tableManager.tableView(QualifiedName.fromSimple(tableName)); assertNotNull(tbl2); diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/storage/InternalTableEstimatedSizeTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/storage/InternalTableEstimatedSizeTest.java index a893f751511..d1f9e3e7558 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/storage/InternalTableEstimatedSizeTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/storage/InternalTableEstimatedSizeTest.java @@ -80,6 +80,7 @@ import org.apache.ignite.internal.replicator.message.ReplicaRequest; import org.apache.ignite.internal.schema.SchemaRegistry; import org.apache.ignite.internal.schema.SchemaSyncService; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.storage.MvPartitionStorage; import org.apache.ignite.internal.storage.engine.MvTableStorage; import org.apache.ignite.internal.table.InternalTable; @@ -103,6 +104,7 @@ import org.apache.ignite.internal.util.PendingComparableValuesTracker; import org.apache.ignite.network.ClusterNode; import org.apache.ignite.network.NetworkAddress; +import org.apache.ignite.table.QualifiedNameHelper; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -197,7 +199,7 @@ void setUp( var clockService = new ClockServiceImpl(clock, clockWaiter, () -> 0); table = new InternalTableImpl( - TABLE_NAME, + QualifiedNameHelper.fromNormalized(SqlCommon.DEFAULT_SCHEMA_NAME, TABLE_NAME), TABLE_ID, PARTITIONS_NUM, clusterService.topologyService(), diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImplTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImplTest.java index f1cce5eebc5..24f30f06dad 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImplTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImplTest.java @@ -42,6 +42,7 @@ import org.apache.ignite.internal.replicator.ReplicaService; import org.apache.ignite.internal.schema.BinaryRowEx; import org.apache.ignite.internal.schema.NullBinaryRow; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.storage.engine.MvTableStorage; import org.apache.ignite.internal.table.StreamerReceiverRunner; import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; @@ -51,6 +52,7 @@ import org.apache.ignite.internal.tx.storage.state.TxStateTableStorage; import org.apache.ignite.internal.util.PendingComparableValuesTracker; import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.table.QualifiedNameHelper; import org.junit.jupiter.api.Test; /** @@ -60,7 +62,7 @@ public class InternalTableImplTest extends BaseIgniteAbstractTest { @Test void testUpdatePartitionTrackers() { InternalTableImpl internalTable = new InternalTableImpl( - "test", + QualifiedNameHelper.fromNormalized(SqlCommon.DEFAULT_SCHEMA_NAME, "test"), 1, 1, new SingleClusterNodeResolver(mock(ClusterNode.class)), @@ -110,7 +112,7 @@ void testUpdatePartitionTrackers() { @Test void testRowBatchByPartitionId() { InternalTableImpl internalTable = new InternalTableImpl( - "test", + QualifiedNameHelper.fromNormalized(SqlCommon.DEFAULT_SCHEMA_NAME, "test"), 1, 3, new SingleClusterNodeResolver(mock(ClusterNode.class)), diff --git a/modules/table/src/testFixtures/java/org/apache/ignite/distributed/ItTxTestCluster.java b/modules/table/src/testFixtures/java/org/apache/ignite/distributed/ItTxTestCluster.java index 49ab15b1577..79c460c2844 100644 --- a/modules/table/src/testFixtures/java/org/apache/ignite/distributed/ItTxTestCluster.java +++ b/modules/table/src/testFixtures/java/org/apache/ignite/distributed/ItTxTestCluster.java @@ -124,6 +124,7 @@ import org.apache.ignite.internal.schema.SchemaRegistry; import org.apache.ignite.internal.schema.SchemaSyncService; import org.apache.ignite.internal.schema.configuration.StorageUpdateConfiguration; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.storage.MvPartitionStorage; import org.apache.ignite.internal.storage.engine.MvTableStorage; import org.apache.ignite.internal.storage.impl.TestMvPartitionStorage; @@ -178,6 +179,8 @@ import org.apache.ignite.network.NetworkAddress; import org.apache.ignite.raft.jraft.rpc.impl.RaftGroupEventsClientListener; import org.apache.ignite.sql.IgniteSql; +import org.apache.ignite.table.QualifiedName; +import org.apache.ignite.table.QualifiedNameHelper; import org.apache.ignite.tx.IgniteTransactions; import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.TestInfo; @@ -635,7 +638,7 @@ public TableViewInternal startTable(String tableName, SchemaDescriptor schemaDes when(catalogService.indexes(anyInt(), eq(tableId))).thenReturn(List.of(pkCatalogIndexDescriptor)); InternalTableImpl internalTable = new InternalTableImpl( - tableName, + QualifiedNameHelper.fromNormalized(SqlCommon.DEFAULT_SCHEMA_NAME, tableName), tableId, 1, nodeResolver, @@ -922,11 +925,11 @@ private CompletableFuture getRaftClientForGroup(ReplicationGro .thenApply(Replica::raftClient); } - protected Peer getLeaderId(String tableName) { + protected Peer getLeaderId(QualifiedName tableName) { int partId = 0; return replicaManagers.get(extractConsistentId(cluster.get(partId))) - .replica(new TablePartitionId(tables.get(tableName).tableId(), partId)) + .replica(new TablePartitionId(tables.get(tableName.objectName()).tableId(), partId)) .thenApply(replica -> replica.raftClient().leader()) .join(); } diff --git a/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/TableTestUtils.java b/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/TableTestUtils.java index 7d94b9688ea..85bb4214c8b 100644 --- a/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/TableTestUtils.java +++ b/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/TableTestUtils.java @@ -48,6 +48,8 @@ /** Utils to manage tables inside tests. */ public class TableTestUtils { + public static final String SCHEMA_NAME = DEFAULT_SCHEMA_NAME; + /** Table name. */ public static final String TABLE_NAME = "TEST_TABLE"; @@ -194,7 +196,7 @@ public static void createHashIndex( * @param timestamp Timestamp. */ public static @Nullable CatalogTableDescriptor getTable(CatalogService catalogService, String tableName, long timestamp) { - return catalogService.table(tableName, timestamp); + return catalogService.table(DEFAULT_SCHEMA_NAME, tableName, timestamp); } /** @@ -206,7 +208,7 @@ public static void createHashIndex( * @throws AssertionError If table descriptor is absent. */ public static CatalogTableDescriptor getTableStrict(CatalogService catalogService, String tableName, long timestamp) { - CatalogTableDescriptor table = catalogService.table(tableName, timestamp); + CatalogTableDescriptor table = catalogService.table(DEFAULT_SCHEMA_NAME, tableName, timestamp); assertNotNull(table, "tableName=" + tableName + ", timestamp=" + timestamp); @@ -287,7 +289,7 @@ public static int getIndexIdStrict(CatalogService catalogService, String indexNa * @param timestamp Timestamp. */ public static @Nullable CatalogIndexDescriptor getIndex(CatalogService catalogService, String indexName, long timestamp) { - return catalogService.aliveIndex(indexName, timestamp); + return catalogService.aliveIndex(SCHEMA_NAME, indexName, timestamp); } /** @@ -299,7 +301,7 @@ public static int getIndexIdStrict(CatalogService catalogService, String indexNa * @throws AssertionError If table descriptor is absent. */ public static CatalogIndexDescriptor getIndexStrict(CatalogService catalogService, String indexName, long timestamp) { - CatalogIndexDescriptor index = catalogService.aliveIndex(indexName, timestamp); + CatalogIndexDescriptor index = catalogService.aliveIndex(SCHEMA_NAME, indexName, timestamp); assertNotNull(index, "indexName=" + indexName + ", timestamp=" + timestamp); diff --git a/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/impl/DummyInternalTableImpl.java b/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/impl/DummyInternalTableImpl.java index 775480661c5..5259de9879b 100644 --- a/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/impl/DummyInternalTableImpl.java +++ b/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/impl/DummyInternalTableImpl.java @@ -87,6 +87,7 @@ import org.apache.ignite.internal.schema.ColumnsExtractor; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.configuration.StorageUpdateConfiguration; +import org.apache.ignite.internal.sql.SqlCommon; import org.apache.ignite.internal.storage.MvPartitionStorage; import org.apache.ignite.internal.storage.engine.MvTableStorage; import org.apache.ignite.internal.storage.impl.TestMvPartitionStorage; @@ -125,6 +126,7 @@ import org.apache.ignite.internal.util.SafeTimeValuesTracker; import org.apache.ignite.network.ClusterNode; import org.apache.ignite.network.NetworkAddress; +import org.apache.ignite.table.QualifiedNameHelper; import org.apache.ignite.tx.TransactionException; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -256,7 +258,7 @@ public DummyInternalTableImpl( TransactionInflights transactionInflights ) { super( - "test", + QualifiedNameHelper.fromNormalized(SqlCommon.DEFAULT_SCHEMA_NAME, "test"), nextTableId.getAndIncrement(), 1, new SingleClusterNodeResolver(LOCAL_NODE), diff --git a/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryMetricTest.java b/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryMetricTest.java index 07d15b0a504..4497cc99eab 100644 --- a/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryMetricTest.java +++ b/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryMetricTest.java @@ -110,7 +110,8 @@ private DynamicMBean metricSourceMbean(String metricSourceName) throws Exception } private static String partitionStatesMetricSourceName(IgniteImpl node, String tableName) { - CatalogTableDescriptor tableDescriptor = node.catalogManager().table(tableName, node.clock().nowLong()); + CatalogTableDescriptor tableDescriptor = node.catalogManager().table(SCHEMA_NAME, tableName, node.clock().nowLong() + ); return String.format("partition.states.zone.%s.table.%s", tableDescriptor.zoneId(), tableDescriptor.id()); }