This is an automated email from the ASF dual-hosted git repository. amashenkov pushed a commit to branch ignite-19942 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 907b6a163b0137a9c0c5998e884776a26eb6f9d7 Author: amashenkov <andrey.mashen...@gmail.com> AuthorDate: Thu Jul 13 20:07:39 2023 +0300 Get rid of DdlCommandHandlerWrapper. Get rid of unused methods. Fix styles. --- .../internal/catalog/CatalogManagerImpl.java | 2 +- .../internal/catalog/commands/CatalogUtils.java | 3 + .../distributionzones/DistributionZoneManager.java | 8 +- .../apache/ignite/internal/index/IndexManager.java | 176 ++------- .../ignite/internal/index/IndexManagerTest.java | 11 +- .../ignite/internal/index/ItIndexManagerTest.java | 8 +- .../testutils/SchemaToCatalogParamsConverter.java | 3 + .../internal/sql/engine/SqlQueryProcessor.java | 4 +- .../sql/engine/exec/ddl/DdlCommandHandler.java | 403 ++------------------- .../engine/exec/ddl/DdlCommandHandlerWrapper.java | 114 ------ .../DdlCommandHandlerExceptionHandlingTest.java | 2 +- .../ddl/DistributionZoneDdlCommandHandlerTest.java | 6 +- .../internal/table/distributed/TableManager.java | 41 +-- 13 files changed, 86 insertions(+), 695 deletions(-) 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 02e9ca4209..24f413484c 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 @@ -154,7 +154,7 @@ public class CatalogManagerImpl extends Producer<CatalogEvent, CatalogEventParam // TODO: IGNITE-19082 Move default schema objects initialization to cluster init procedure. CatalogSchemaDescriptor schemaPublic = new CatalogSchemaDescriptor( - 0, + objectIdGen++, DEFAULT_SCHEMA_NAME, new CatalogTableDescriptor[0], new CatalogIndexDescriptor[0] diff --git a/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java b/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java index 7d53598e23..4243a54b3d 100644 --- a/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java +++ b/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java @@ -44,18 +44,21 @@ public class CatalogUtils { * <p>SQL`16 part 2 section 6.1 syntax rule 36 */ public static final int DEFAULT_TIMESTAMP_PRECISION = 6; + /** * Default TIME type precision: seconds. * * <p>SQL`16 part 2 section 6.1 syntax rule 36 */ public static final int DEFAULT_TIME_PRECISION = 0; + /** * Default DECIMAL precision is implementation-defined. * * <p>SQL`16 part 2 section 6.1 syntax rule 25 */ public static final int DEFAULT_DECIMAL_PRECISION = 19; + /** * Default DECIMAL scale is implementation-defined. * diff --git a/modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java b/modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java index 97863daf36..8f67682499 100644 --- a/modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java +++ b/modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java @@ -98,7 +98,6 @@ import org.apache.ignite.internal.catalog.commands.AlterZoneParams; import org.apache.ignite.internal.catalog.commands.CreateZoneParams; import org.apache.ignite.internal.catalog.commands.DropZoneParams; import org.apache.ignite.internal.catalog.commands.RenameZoneParams; -import org.apache.ignite.internal.catalog.descriptors.CatalogZoneDescriptor; import org.apache.ignite.internal.cluster.management.topology.api.LogicalNode; import org.apache.ignite.internal.cluster.management.topology.api.LogicalTopologyEventListener; import org.apache.ignite.internal.cluster.management.topology.api.LogicalTopologyService; @@ -409,12 +408,7 @@ public class DistributionZoneManager implements IgniteComponent { .dataNodesAutoAdjustScaleDown(distributionZoneCfg.dataNodesAutoAdjustScaleDown()) .build()) .thenApply(ignore -> catalogManager.zone(distributionZoneCfg.name(), Long.MAX_VALUE)) - .thenCompose(zoneDescriptor -> createZone(zoneDescriptor.id(), distributionZoneCfg)) - .whenComplete((id, ex) -> { - if (ex != null) { - LOG.warn("Failed to create zone.", ex); - } - }); + .thenCompose(zoneDescriptor -> createZone(zoneDescriptor.id(), distributionZoneCfg)); } finally { busyLock.leaveBusy(); } diff --git a/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java b/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java index 2944ef3f6e..d14dc9dfd5 100644 --- a/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java +++ b/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java @@ -33,10 +33,10 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import java.util.function.Function; -import org.apache.ignite.configuration.NamedListView; import org.apache.ignite.configuration.notifications.ConfigurationNamedListListener; import org.apache.ignite.configuration.notifications.ConfigurationNotificationEvent; import org.apache.ignite.internal.catalog.CatalogManager; +import org.apache.ignite.internal.catalog.commands.AbstractIndexCommandParams; import org.apache.ignite.internal.catalog.commands.CreateHashIndexParams; import org.apache.ignite.internal.catalog.commands.CreateSortedIndexParams; import org.apache.ignite.internal.catalog.commands.DropIndexParams; @@ -191,106 +191,52 @@ public class IndexManager extends Producer<IndexEvent, IndexEventParameters> imp } /** - * Creates index from provided configuration changer. - * - * @param schemaName A name of the schema to create index in. - * @param indexName A name of the index to create. - * @param tableName A name of the table to create index for. - * @param failIfExists Flag indicates whether exception be thrown if index exists or not. - * @param indexChange A consumer that suppose to change the configuration in order to provide description of an index. - * @return A future represented the result of creation. - */ - @Deprecated(forRemoval = true) - public CompletableFuture<Boolean> createIndexAsync( - String schemaName, - String indexName, - String tableName, - boolean failIfExists, - Consumer<TableIndexChange> indexChange - ) { - throw new UnsupportedOperationException("Method is no longer supported."); - } - - /** - * Creates sorted index from provided parameters. + * Creates index from provided parameters. */ - @Deprecated(forRemoval = true) - public CompletableFuture<Boolean> createSortedIndexAsync(CreateSortedIndexParams params) { + public CompletableFuture<Boolean> createIndexAsync(AbstractIndexCommandParams params) { if (!busyLock.enterBusy()) { return failedFuture(new NodeStoppingException()); } try { - Consumer<TableIndexChange> indexChanger = tableIndexChange -> { - tableIndexChange.convert(SortedIndexChange.class).changeColumns(colsInit -> { - for (int i = 0; i < params.columns().size(); i++) { - String columnName = params.columns().get(i); - CatalogColumnCollation collation = params.collations().get(i); - //TODO: https://issues.apache.org/jira/browse/IGNITE-17563 Pass null ordering for columns. - colsInit.create(columnName, colInit -> colInit.changeAsc(collation.asc())); - } - }); - }; - - return catalogManager.createIndex(params) - .thenApply(ignore -> { - CatalogIndexDescriptor index = catalogManager.index(params.indexName(), Long.MAX_VALUE); - return index.id(); - }) - .thenCompose(indexId -> - createIndexInternal( - indexId, - params.schemaName(), - params.indexName(), - params.tableName(), - true, - indexChanger - ) - ); - } catch (Exception ex) { - return failedFuture(ex); + CompletableFuture<Void> indexCreateFuture = (params instanceof CreateSortedIndexParams) + ? catalogManager.createIndex((CreateSortedIndexParams) params) + : catalogManager.createIndex((CreateHashIndexParams) params); + + return indexCreateFuture.thenApply(ignore -> catalogManager.index(params.indexName(), Long.MAX_VALUE)) + .thenCompose(index -> createIndexInternal( + index.id(), + params.schemaName(), + params.indexName(), + params.tableName(), + true, + createIndexChanger(params) + )); } finally { busyLock.leaveBusy(); } } - /** - * Creates hash index from provided parameters. - */ @Deprecated(forRemoval = true) - public CompletableFuture<Boolean> createHashIndexAsync(CreateHashIndexParams params) { - if (!busyLock.enterBusy()) { - return failedFuture(new NodeStoppingException()); - } - - try { - Consumer<TableIndexChange> indexChanger = tableIndexChange -> { - tableIndexChange.convert(HashIndexChange.class) - .changeColumnNames(params.columns().toArray(STRING_EMPTY_ARRAY)); - }; - - return catalogManager.createIndex(params) - .thenApply(ignore -> { - CatalogIndexDescriptor index = catalogManager.index(params.indexName(), Long.MAX_VALUE); - return index.id(); - }) - .thenCompose(indexId -> - createIndexInternal( - indexId, - params.schemaName(), - params.indexName(), - params.tableName(), - true, - indexChanger - ) - ); - } catch (Exception ex) { - return failedFuture(ex); - } finally { - busyLock.leaveBusy(); + private Consumer<TableIndexChange> createIndexChanger(AbstractIndexCommandParams indexParams) { + if (indexParams instanceof CreateSortedIndexParams) { + CreateSortedIndexParams params = (CreateSortedIndexParams) indexParams; + return tableIndexChange -> tableIndexChange.convert(SortedIndexChange.class).changeColumns(colsInit -> { + for (int i = 0; i < params.columns().size(); i++) { + String columnName = params.columns().get(i); + CatalogColumnCollation collation = params.collations().get(i); + //TODO: https://issues.apache.org/jira/browse/IGNITE-17563 Pass null ordering for columns. + colsInit.create(columnName, colInit -> colInit.changeAsc(collation.asc())); + } + }); + } else { + CreateHashIndexParams params = (CreateHashIndexParams) indexParams; + return tableIndexChange -> tableIndexChange.convert(HashIndexChange.class) + .changeColumnNames(params.columns().toArray(STRING_EMPTY_ARRAY)); } } + @Deprecated(forRemoval = true) private CompletableFuture<Boolean> createIndexInternal( int indexId, String schemaName, @@ -366,29 +312,11 @@ public class IndexManager extends Producer<IndexEvent, IndexEventParameters> imp }); return future; - } catch (Exception ex) { - return failedFuture(ex); } finally { busyLock.leaveBusy(); } } - /** - * Drops the index with a given name asynchronously. - * - * @param schemaName A name of the schema the index belong to. - * @param indexName A name of the index to drop. - * @param failIfNotExists Flag, which force failure, when {@code trues} if index doen't not exists. - * @return A future representing the result of the operation. - */ - public CompletableFuture<Boolean> dropIndexAsync( - String schemaName, - String indexName, - boolean failIfNotExists - ) { - throw new UnsupportedOperationException("Method is no longer supported."); - } - /** * Drops the index with a given parameters asynchronously. */ @@ -397,17 +325,14 @@ public class IndexManager extends Producer<IndexEvent, IndexEventParameters> imp throw new IgniteException(new NodeStoppingException()); } try { - CompletableFuture<Boolean> future = catalogManager.dropIndex(params) + return catalogManager.dropIndex(params) .thenCompose(ignore -> dropIndexAsyncInternal(params.schemaName(), params.indexName(), true)); - - future.whenComplete((res, ex) -> ex.printStackTrace()); - - return future; } finally { busyLock.leaveBusy(); } } + @Deprecated(forRemoval = true) private CompletableFuture<Boolean> dropIndexAsyncInternal( String schemaName, String indexName, @@ -456,44 +381,11 @@ public class IndexManager extends Producer<IndexEvent, IndexEventParameters> imp }); return future; - } catch (Exception ex) { - return failedFuture(ex); } finally { busyLock.leaveBusy(); } } - /** - * Gets a list of index configuration views for the specified table. - * - * @param tableName Table name. - * @return List of index configuration views. - */ - public List<TableIndexView> indexConfigurations(String tableName) { - List<TableIndexView> res = new ArrayList<>(); - Integer targetTableId = null; - - NamedListView<TableView> tablesView = tablesCfg.tables().value(); - - for (TableIndexView cfg : tablesCfg.indexes().value()) { - if (targetTableId == null) { - TableView tbl = findTableView(tablesView, cfg.tableId()); - - if (tbl == null || !tableName.equals(tbl.name())) { - continue; - } - - targetTableId = cfg.tableId(); - } else if (!targetTableId.equals(cfg.tableId())) { - continue; - } - - res.add(cfg); - } - - return res; - } - private void validateName(String indexName) { if (StringUtils.nullOrEmpty(indexName)) { throw new IgniteInternalException( diff --git a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java index 40fb2c13f7..53b2abf6d2 100644 --- a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java +++ b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java @@ -141,14 +141,15 @@ public class IndexManagerTest { void configurationChangedWhenCreateIsInvoked() { String indexName = "idx"; - assertThat(indexManager.createSortedIndexAsync( + assertThat(indexManager.createIndexAsync( CreateSortedIndexParams.builder() .schemaName(CatalogManager.DEFAULT_SCHEMA_NAME) .tableName("tName") .indexName(indexName) .columns(List.of("c1", "c2")) .collations(List.of(CatalogColumnCollation.ASC_NULLS_LAST, CatalogColumnCollation.DESC_NULLS_FIRST)) - .build()), willCompleteSuccessfully()); + .build()), + willCompleteSuccessfully()); var expected = List.of( Map.of( @@ -176,7 +177,7 @@ public class IndexManagerTest { @Test public void createIndexWithEmptyName() { assertThat( - indexManager.createHashIndexAsync( + indexManager.createIndexAsync( CreateHashIndexParams.builder() .schemaName(CatalogManager.DEFAULT_SCHEMA_NAME) .tableName("tName") @@ -187,7 +188,7 @@ public class IndexManagerTest { ); assertThat( - indexManager.createSortedIndexAsync( + indexManager.createIndexAsync( CreateSortedIndexParams.builder() .schemaName(CatalogManager.DEFAULT_SCHEMA_NAME) .tableName("tName") @@ -229,7 +230,7 @@ public class IndexManagerTest { return completedFuture(true); }); - assertThat(indexManager.createSortedIndexAsync( + assertThat(indexManager.createIndexAsync( CreateSortedIndexParams.builder() .schemaName(CatalogManager.DEFAULT_SCHEMA_NAME) .indexName(indexName) diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexManagerTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexManagerTest.java index 3c7eca2188..242c4fbdca 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexManagerTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexManagerTest.java @@ -70,7 +70,7 @@ public class ItIndexManagerTest extends ClusterPerClassIntegrationTest { CompletableFuture<IndexEventParameters> indexCreatedFuture = registerListener(indexManager, IndexEvent.CREATE); - await(indexManager.createHashIndexAsync( + await(indexManager.createIndexAsync( CreateHashIndexParams.builder() .schemaName("PUBLIC") .indexName("INAME") @@ -93,11 +93,7 @@ public class ItIndexManagerTest extends ClusterPerClassIntegrationTest { CompletableFuture<IndexEventParameters> indexDroppedFuture = registerListener(indexManager, IndexEvent.DROP); - await(indexManager.dropIndexAsync( - DropIndexParams.builder() - .schemaName("PUBLIC") - .indexName("INAME") - .build())); + await(indexManager.dropIndexAsync(DropIndexParams.builder().schemaName("PUBLIC").indexName("INAME").build())); { IndexEventParameters params = await(indexDroppedFuture); diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/SchemaToCatalogParamsConverter.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/SchemaToCatalogParamsConverter.java index a00eda8c7f..8c5aff76fd 100644 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/SchemaToCatalogParamsConverter.java +++ b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/SchemaToCatalogParamsConverter.java @@ -39,6 +39,7 @@ public class SchemaToCatalogParamsConverter { * Types map. */ private static final EnumSet<ColumnType.ColumnTypeSpec> fixSizedTypes = EnumSet.of( + ColumnType.BOOLEAN.typeSpec(), ColumnType.INT8.typeSpec(), ColumnType.INT16.typeSpec(), ColumnType.INT32.typeSpec(), @@ -116,6 +117,8 @@ public class SchemaToCatalogParamsConverter { private static org.apache.ignite.sql.ColumnType convert(ColumnType colType) { switch (colType.typeSpec()) { + case BOOLEAN: + return org.apache.ignite.sql.ColumnType.BOOLEAN; case INT8: return org.apache.ignite.sql.ColumnType.INT8; case INT16: diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java index f67294f396..a0b5c9bc24 100644 --- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java +++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java @@ -62,7 +62,7 @@ import org.apache.ignite.internal.sql.engine.exec.MailboxRegistryImpl; import org.apache.ignite.internal.sql.engine.exec.QueryTaskExecutor; import org.apache.ignite.internal.sql.engine.exec.QueryTaskExecutorImpl; import org.apache.ignite.internal.sql.engine.exec.QueryValidationException; -import org.apache.ignite.internal.sql.engine.exec.ddl.DdlCommandHandlerWrapper; +import org.apache.ignite.internal.sql.engine.exec.ddl.DdlCommandHandler; import org.apache.ignite.internal.sql.engine.message.MessageServiceImpl; import org.apache.ignite.internal.sql.engine.prepare.PrepareService; import org.apache.ignite.internal.sql.engine.prepare.PrepareServiceImpl; @@ -249,7 +249,7 @@ public class SqlQueryProcessor implements QueryProcessor { this.prepareSvc = prepareSvc; - var ddlCommandHandler = new DdlCommandHandlerWrapper( + var ddlCommandHandler = new DdlCommandHandler( distributionZoneManager, tableManager, indexManager, diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandler.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandler.java index 5760dc2a85..e8ec21d5eb 100644 --- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandler.java +++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandler.java @@ -19,97 +19,52 @@ package org.apache.ignite.internal.sql.engine.exec.ddl; import static java.util.concurrent.CompletableFuture.completedFuture; import static java.util.concurrent.CompletableFuture.failedFuture; -import static org.apache.ignite.internal.distributionzones.DistributionZoneManager.DEFAULT_ZONE_NAME; -import static org.apache.ignite.internal.sql.engine.SqlQueryProcessor.DEFAULT_SCHEMA_NAME; import static org.apache.ignite.internal.util.CollectionUtils.nullOrEmpty; import static org.apache.ignite.lang.ErrorGroups.Sql.STMT_VALIDATION_ERR; +import static org.apache.ignite.lang.ErrorGroups.Sql.UNSUPPORTED_DDL_OPERATION_ERR; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiFunction; -import java.util.function.Consumer; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import org.apache.ignite.configuration.NamedListView; +import org.apache.ignite.internal.catalog.CatalogManager; import org.apache.ignite.internal.distributionzones.DistributionZoneConfigurationParameters; import org.apache.ignite.internal.distributionzones.DistributionZoneManager; import org.apache.ignite.internal.index.IndexManager; -import org.apache.ignite.internal.schema.BitmaskNativeType; -import org.apache.ignite.internal.schema.DecimalNativeType; -import org.apache.ignite.internal.schema.NativeType; -import org.apache.ignite.internal.schema.NativeTypeSpec; -import org.apache.ignite.internal.schema.NumberNativeType; -import org.apache.ignite.internal.schema.TemporalNativeType; -import org.apache.ignite.internal.schema.VarlenNativeType; -import org.apache.ignite.internal.schema.configuration.ColumnChange; -import org.apache.ignite.internal.schema.configuration.ColumnTypeChange; -import org.apache.ignite.internal.schema.configuration.ColumnView; -import org.apache.ignite.internal.schema.configuration.PrimaryKeyView; -import org.apache.ignite.internal.schema.configuration.TableChange; -import org.apache.ignite.internal.schema.configuration.ValueSerializationHelper; -import org.apache.ignite.internal.schema.configuration.defaultvalue.ConstantValueDefaultChange; -import org.apache.ignite.internal.schema.configuration.defaultvalue.FunctionCallDefaultChange; -import org.apache.ignite.internal.schema.configuration.defaultvalue.NullValueDefaultChange; -import org.apache.ignite.internal.schema.configuration.index.HashIndexChange; -import org.apache.ignite.internal.schema.configuration.index.HashIndexView; -import org.apache.ignite.internal.schema.configuration.index.IndexColumnView; -import org.apache.ignite.internal.schema.configuration.index.SortedIndexChange; -import org.apache.ignite.internal.schema.configuration.index.SortedIndexView; -import org.apache.ignite.internal.schema.configuration.index.TableIndexChange; -import org.apache.ignite.internal.schema.configuration.index.TableIndexView; import org.apache.ignite.internal.sql.engine.prepare.ddl.AbstractTableDdlCommand; import org.apache.ignite.internal.sql.engine.prepare.ddl.AlterColumnCommand; import org.apache.ignite.internal.sql.engine.prepare.ddl.AlterTableAddCommand; import org.apache.ignite.internal.sql.engine.prepare.ddl.AlterTableDropCommand; import org.apache.ignite.internal.sql.engine.prepare.ddl.AlterZoneRenameCommand; import org.apache.ignite.internal.sql.engine.prepare.ddl.AlterZoneSetCommand; -import org.apache.ignite.internal.sql.engine.prepare.ddl.ColumnDefinition; import org.apache.ignite.internal.sql.engine.prepare.ddl.CreateIndexCommand; import org.apache.ignite.internal.sql.engine.prepare.ddl.CreateTableCommand; import org.apache.ignite.internal.sql.engine.prepare.ddl.CreateZoneCommand; import org.apache.ignite.internal.sql.engine.prepare.ddl.DdlCommand; -import org.apache.ignite.internal.sql.engine.prepare.ddl.DefaultValueDefinition.ConstantValue; -import org.apache.ignite.internal.sql.engine.prepare.ddl.DefaultValueDefinition.FunctionCall; import org.apache.ignite.internal.sql.engine.prepare.ddl.DropIndexCommand; import org.apache.ignite.internal.sql.engine.prepare.ddl.DropTableCommand; import org.apache.ignite.internal.sql.engine.prepare.ddl.DropZoneCommand; -import org.apache.ignite.internal.sql.engine.schema.IgniteIndex.Collation; -import org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory; import org.apache.ignite.internal.storage.DataStorageManager; import org.apache.ignite.internal.table.distributed.TableManager; -import org.apache.ignite.internal.util.ArrayUtils; import org.apache.ignite.internal.util.StringUtils; -import org.apache.ignite.lang.ColumnAlreadyExistsException; -import org.apache.ignite.lang.ColumnNotFoundException; import org.apache.ignite.lang.DistributionZoneAlreadyExistsException; import org.apache.ignite.lang.DistributionZoneNotFoundException; -import org.apache.ignite.lang.ErrorGroups; -import org.apache.ignite.lang.ErrorGroups.Table; -import org.apache.ignite.lang.IgniteStringBuilder; -import org.apache.ignite.lang.IgniteStringFormatter; +import org.apache.ignite.lang.IndexAlreadyExistsException; +import org.apache.ignite.lang.IndexNotFoundException; import org.apache.ignite.lang.TableAlreadyExistsException; import org.apache.ignite.lang.TableNotFoundException; -import org.apache.ignite.sql.SqlException; /** DDL commands handler. */ public class DdlCommandHandler { private final DistributionZoneManager distributionZoneManager; - protected final TableManager tableManager; + private final TableManager tableManager; - protected final IndexManager indexManager; + private final IndexManager indexManager; private final DataStorageManager dataStorageManager; + private final CatalogManager catalogManager; + /** * Constructor. */ @@ -117,12 +72,14 @@ public class DdlCommandHandler { DistributionZoneManager distributionZoneManager, TableManager tableManager, IndexManager indexManager, - DataStorageManager dataStorageManager + DataStorageManager dataStorageManager, + CatalogManager catalogManager ) { this.distributionZoneManager = distributionZoneManager; this.tableManager = tableManager; this.indexManager = indexManager; this.dataStorageManager = dataStorageManager; + this.catalogManager = catalogManager; } /** Handles ddl commands. */ @@ -138,7 +95,7 @@ public class DdlCommandHandler { } else if (cmd instanceof AlterTableDropCommand) { return handleAlterDropColumn((AlterTableDropCommand) cmd); } else if (cmd instanceof AlterColumnCommand) { - return completedFuture(true); + return handleAlterColumn((AlterColumnCommand) cmd); } else if (cmd instanceof CreateIndexCommand) { return handleCreateIndex((CreateIndexCommand) cmd); } else if (cmd instanceof DropIndexCommand) { @@ -258,51 +215,13 @@ public class DdlCommandHandler { /** Handles create table command. */ private CompletableFuture<Boolean> handleCreateTable(CreateTableCommand cmd) { - cmd.columns().stream() - .map(ColumnDefinition::name) - .filter(Predicate.not(new HashSet<>()::add)) - .findAny() - .ifPresent(col -> { - throw new SqlException(Table.TABLE_DEFINITION_ERR, "Can't create table with duplicate columns: " - + cmd.columns().stream().map(ColumnDefinition::name).collect(Collectors.joining(", "))); - }); - - Consumer<TableChange> tblChanger = tableChange -> { - tableChange.changeColumns(columnsChange -> { - for (var col : cmd.columns()) { - columnsChange.create(col.name(), columnChange -> convertColumnDefinition(col, columnChange)); - } - }); - - var colocationKeys = cmd.colocationColumns(); - - if (nullOrEmpty(colocationKeys)) { - colocationKeys = cmd.primaryKeyColumns(); - } - - var colocationKeys0 = colocationKeys; - - tableChange.changePrimaryKey(pkChange -> pkChange.changeColumns(cmd.primaryKeyColumns().toArray(String[]::new)) - .changeColocationColumns(colocationKeys0.toArray(String[]::new))); - }; - - String zoneName; - - if (cmd.zone() != null) { - zoneName = cmd.zone(); - } else { - zoneName = DEFAULT_ZONE_NAME; - } - - return tableManager.createTableAsync(cmd.tableName(), zoneName, tblChanger) - .thenApply(Objects::nonNull) + return tableManager.createTableAsync(DdlToCatalogCommandConverter.convert(cmd)) .handle(handleModificationResult(cmd.ifTableExists(), TableAlreadyExistsException.class)); } /** Handles drop table command. */ private CompletableFuture<Boolean> handleDropTable(DropTableCommand cmd) { - return tableManager.dropTableAsync(cmd.tableName()) - .thenApply(v -> Boolean.TRUE) + return tableManager.dropTableAsync(DdlToCatalogCommandConverter.convert(cmd)) .handle(handleModificationResult(cmd.ifTableExists(), TableNotFoundException.class)); } @@ -312,7 +231,7 @@ public class DdlCommandHandler { return completedFuture(Boolean.FALSE); } - return addColumnInternal(cmd.tableName(), cmd.columns()) + return tableManager.alterTableAddColumnAsync(DdlToCatalogCommandConverter.convert(cmd)) .handle(handleModificationResult(cmd.ifTableExists(), TableNotFoundException.class)); } @@ -322,11 +241,17 @@ public class DdlCommandHandler { return completedFuture(Boolean.FALSE); } - return dropColumnInternal(cmd.tableName(), cmd.columns()) + return tableManager.alterTableDropColumnAsync(DdlToCatalogCommandConverter.convert(cmd)) .handle(handleModificationResult(cmd.ifTableExists(), TableNotFoundException.class)); } - protected static BiFunction<Object, Throwable, Boolean> handleModificationResult(boolean ignoreExpectedError, Class<?> expErrCls) { + /** Handles alter column command. */ + private CompletableFuture<Boolean> handleAlterColumn(AlterColumnCommand cmd) { + return catalogManager.alterColumn(DdlToCatalogCommandConverter.convert(cmd)) + .handle(handleModificationResult(cmd.ifTableExists(), TableNotFoundException.class)); + } + + private static BiFunction<Object, Throwable, Boolean> handleModificationResult(boolean ignoreExpectedError, Class<?> expErrCls) { return (val, err) -> { if (err == null) { return val instanceof Boolean ? (Boolean) val : Boolean.TRUE; @@ -344,287 +269,13 @@ public class DdlCommandHandler { /** Handles create index command. */ private CompletableFuture<Boolean> handleCreateIndex(CreateIndexCommand cmd) { - cmd.columns().stream() - .filter(Predicate.not(new HashSet<>()::add)) - .findAny() - .ifPresent(col -> { - throw new SqlException(ErrorGroups.Index.INVALID_INDEX_DEFINITION_ERR, - "Can't create index on duplicate columns: " + String.join(", ", cmd.columns())); - }); - - Consumer<TableIndexChange> indexChanger = tableIndexChange -> { - switch (cmd.type()) { - case SORTED: - createSortedIndexInternal(cmd, tableIndexChange.convert(SortedIndexChange.class)); - - break; - case HASH: - createHashIndexInternal(cmd, tableIndexChange.convert(HashIndexChange.class)); - - break; - default: - throw new AssertionError("Unknown index type [type=" + cmd.type() + "]"); - } - }; - - return indexManager.createIndexAsync( - cmd.schemaName(), - cmd.indexName(), - cmd.tableName(), - !cmd.ifNotExists(), - indexChanger); + return indexManager.createIndexAsync(DdlToCatalogCommandConverter.convert(cmd)) + .handle(handleModificationResult(cmd.ifNotExists(), IndexAlreadyExistsException.class)); } /** Handles drop index command. */ private CompletableFuture<Boolean> handleDropIndex(DropIndexCommand cmd) { - return indexManager.dropIndexAsync(cmd.schemaName(), cmd.indexName(), !cmd.ifNotExists()); - } - - /** - * Creates sorted index. - * - * @param cmd Create index command. - * @param indexChange Index configuration changer. - */ - private void createSortedIndexInternal(CreateIndexCommand cmd, SortedIndexChange indexChange) { - indexChange.changeColumns(colsInit -> { - for (int i = 0; i < cmd.columns().size(); i++) { - String columnName = cmd.columns().get(i); - Collation collation = cmd.collations().get(i); - //TODO: https://issues.apache.org/jira/browse/IGNITE-17563 Pass null ordering for columns. - colsInit.create(columnName, colInit -> colInit.changeAsc(collation.asc)); - } - }); - } - - /** - * Creates hash index. - * - * @param cmd Create index command. - * @param indexChange Index configuration changer. - */ - private void createHashIndexInternal(CreateIndexCommand cmd, HashIndexChange indexChange) { - indexChange.changeColumnNames(cmd.columns().toArray(ArrayUtils.STRING_EMPTY_ARRAY)); - } - - /** - * Adds a column according to the column definition. - * - * @param fullName Table with schema name. - * @param colsDef Columns defenitions. - * @return {@code true} if the full columns set is applied successfully. Otherwise, returns {@code false}. - */ - private CompletableFuture<Boolean> addColumnInternal(String fullName, List<ColumnDefinition> colsDef) { - AtomicBoolean retUsr = new AtomicBoolean(true); - - return tableManager.alterTableAsync( - fullName, - chng -> { - AtomicBoolean retTbl = new AtomicBoolean(); - - chng.changeColumns(cols -> { - retUsr.set(true); // Reset state if closure have been restarted. - - Set<String> colNamesToOrders = columnNames(chng.columns()); - - colsDef.stream() - .filter(k -> colNamesToOrders.contains(k.name())) - .findAny() - .ifPresent(c -> { - throw new ColumnAlreadyExistsException(c.name()); - }); - - for (ColumnDefinition col : colsDef) { - cols.create(col.name(), colChg -> convertColumnDefinition(col, colChg)); - } - - retTbl.set(!colsDef.isEmpty()); - }); - - return retTbl.get(); - } - ).thenApply(v -> retUsr.get()); - } - - private void convertColumnDefinition(ColumnDefinition definition, ColumnChange columnChange) { - NativeType columnType = IgniteTypeFactory.relDataTypeToNative(definition.type()); - - columnChange.changeType(columnTypeChange -> convert(columnType, columnTypeChange)); - columnChange.changeNullable(definition.nullable()); - columnChange.changeDefaultValueProvider(defaultChange -> { - switch (definition.defaultValueDefinition().type()) { - case CONSTANT: - ConstantValue constantValue = definition.defaultValueDefinition(); - - var val = constantValue.value(); - - if (val != null) { - defaultChange.convert(ConstantValueDefaultChange.class) - .changeDefaultValue(ValueSerializationHelper.toString(val, columnType)); - } else { - defaultChange.convert(NullValueDefaultChange.class); - } - - break; - case FUNCTION_CALL: - FunctionCall functionCall = definition.defaultValueDefinition(); - - defaultChange.convert(FunctionCallDefaultChange.class) - .changeFunctionName(functionCall.functionName()); - - break; - default: - throw new IllegalStateException("Unknown default value definition type [type=" - + definition.defaultValueDefinition().type() + ']'); - } - }); - } - - /** - * Drops a column(s) exceptional behavior depends on {@code colExist} flag. - * - * @param tableName Table name. - * @param colNames Columns definitions. - * @return {@code true} if the full columns set is applied successfully. Otherwise, returns {@code false}. - */ - private CompletableFuture<Boolean> dropColumnInternal(String tableName, Set<String> colNames) { - AtomicBoolean ret = new AtomicBoolean(true); - - return tableManager.alterTableAsync( - tableName, - chng -> { - chng.changeColumns(cols -> { - ret.set(true); // Reset state if closure have been restarted. - - PrimaryKeyView priKey = chng.primaryKey(); - - Set<String> colNamesToOrders = columnNames(chng.columns()); - - Set<String> colNames0 = new HashSet<>(); - - Set<String> primaryCols = Set.of(priKey.columns()); - - reportIndexedColumns(tableName, colNames, primaryCols); - - for (String colName : colNames) { - if (!colNamesToOrders.contains(colName)) { - ret.set(false); - - throw new ColumnNotFoundException(DEFAULT_SCHEMA_NAME, tableName, colName); - } else { - colNames0.add(colName); - } - - if (primaryCols.contains(colName)) { - throw new SqlException(STMT_VALIDATION_ERR, IgniteStringFormatter - .format("Can`t delete column, belongs to primary key: [name={}]", colName)); - } - } - - colNames0.forEach(cols::delete); - }); - - return ret.get(); - }).thenApply(v -> ret.get()); - } - - private void reportIndexedColumns(String tableName, Set<String> colNames, Set<String> pkColNames) throws SqlException { - Map<String, List<String>> indexedColumns = new HashMap<>(); - - for (TableIndexView idxCfg : indexManager.indexConfigurations(tableName)) { - if (idxCfg instanceof SortedIndexView) { - for (IndexColumnView colView : ((SortedIndexView) idxCfg).columns()) { - if (colNames.contains(colView.name()) && !pkColNames.contains(colView.name())) { - indexedColumns.computeIfAbsent(colView.name(), v -> new ArrayList<>()).add(idxCfg.name()); - } - } - } else if (idxCfg instanceof HashIndexView) { - for (String colName : ((HashIndexView) idxCfg).columnNames()) { - if (colNames.contains(colName) && !pkColNames.contains(colName)) { - indexedColumns.computeIfAbsent(colName, v -> new ArrayList<>()).add(idxCfg.name()); - } - } - } - } - - if (indexedColumns.isEmpty()) { - return; - } - - IgniteStringBuilder sb = new IgniteStringBuilder("Can`t delete column(s). "); - - for (Entry<String, List<String>> e : indexedColumns.entrySet()) { - sb.app("Column ").app(e.getKey()).app(" is used by indexes ").app(e.getValue()).app(". "); - } - - throw new SqlException(STMT_VALIDATION_ERR, sb.toString()); - } - - private static void convert(NativeType colType, ColumnTypeChange colTypeChg) { - NativeTypeSpec spec = colType.spec(); - String typeName = spec.name().toUpperCase(); - - colTypeChg.changeType(typeName); - - switch (spec) { - case BOOLEAN: - case INT8: - case INT16: - case INT32: - case INT64: - case FLOAT: - case DOUBLE: - case DATE: - case UUID: - // do nothing - break; - - case BITMASK: - BitmaskNativeType bitmaskColType = (BitmaskNativeType) colType; - - colTypeChg.changeLength(bitmaskColType.bits()); - - break; - - case BYTES: - case STRING: - VarlenNativeType varLenColType = (VarlenNativeType) colType; - - colTypeChg.changeLength(varLenColType.length()); - - break; - - case DECIMAL: - DecimalNativeType numColType = (DecimalNativeType) colType; - - colTypeChg.changePrecision(numColType.precision()); - colTypeChg.changeScale(numColType.scale()); - - break; - - case NUMBER: - NumberNativeType numType = (NumberNativeType) colType; - - colTypeChg.changePrecision(numType.precision()); - - break; - - case TIME: - case DATETIME: - case TIMESTAMP: - TemporalNativeType temporalColType = (TemporalNativeType) colType; - - colTypeChg.changePrecision(temporalColType.precision()); - - break; - - default: - throw new IllegalArgumentException("Unknown type " + colType.spec().name()); - } - } - - /** Column names set. */ - private static Set<String> columnNames(NamedListView<? extends ColumnView> cols) { - return new HashSet<>(cols.namedListKeys()); + return indexManager.dropIndexAsync(DdlToCatalogCommandConverter.convert(cmd)) + .handle(handleModificationResult(cmd.ifNotExists(), IndexNotFoundException.class)); } } diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerWrapper.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerWrapper.java deleted file mode 100644 index 7fbd884f9b..0000000000 --- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerWrapper.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.sql.engine.exec.ddl; - -import static java.util.concurrent.CompletableFuture.failedFuture; -import static org.apache.ignite.lang.ErrorGroups.Sql.UNSUPPORTED_DDL_OPERATION_ERR; - -import java.util.Objects; -import java.util.concurrent.CompletableFuture; -import org.apache.ignite.internal.catalog.CatalogManager; -import org.apache.ignite.internal.catalog.commands.AbstractIndexCommandParams; -import org.apache.ignite.internal.catalog.commands.CreateHashIndexParams; -import org.apache.ignite.internal.catalog.commands.CreateSortedIndexParams; -import org.apache.ignite.internal.distributionzones.DistributionZoneManager; -import org.apache.ignite.internal.index.IndexManager; -import org.apache.ignite.internal.sql.engine.prepare.ddl.AlterColumnCommand; -import org.apache.ignite.internal.sql.engine.prepare.ddl.AlterTableAddCommand; -import org.apache.ignite.internal.sql.engine.prepare.ddl.AlterTableDropCommand; -import org.apache.ignite.internal.sql.engine.prepare.ddl.CreateIndexCommand; -import org.apache.ignite.internal.sql.engine.prepare.ddl.CreateTableCommand; -import org.apache.ignite.internal.sql.engine.prepare.ddl.DdlCommand; -import org.apache.ignite.internal.sql.engine.prepare.ddl.DropIndexCommand; -import org.apache.ignite.internal.sql.engine.prepare.ddl.DropTableCommand; -import org.apache.ignite.internal.storage.DataStorageManager; -import org.apache.ignite.internal.table.distributed.TableManager; -import org.apache.ignite.lang.IgniteInternalCheckedException; -import org.apache.ignite.lang.IndexAlreadyExistsException; -import org.apache.ignite.lang.IndexNotFoundException; -import org.apache.ignite.lang.TableAlreadyExistsException; -import org.apache.ignite.lang.TableNotFoundException; - -/** - * Wrapper for DDL command handler passes DDL commands to CatalogService. - * TODO: IGNITE-19082 Drop this wrapper when all the versioned schema stuff will be moved from Configuration to Catalog. - */ -public class DdlCommandHandlerWrapper extends DdlCommandHandler { - - private final CatalogManager catalogManager; - - /** - * Constructor. - */ - public DdlCommandHandlerWrapper( - DistributionZoneManager distributionZoneManager, - TableManager tableManager, - IndexManager indexManager, - DataStorageManager dataStorageManager, - CatalogManager catalogManager - ) { - super(distributionZoneManager, tableManager, indexManager, dataStorageManager); - - this.catalogManager = Objects.requireNonNull(catalogManager, "Catalog service"); - } - - /** Handles ddl commands. */ - @Override - public CompletableFuture<Boolean> handle(DdlCommand cmd) { - // TODO IGNITE-19082 replace TableManager with CatalogManager calls. - if (cmd instanceof CreateTableCommand) { - return tableManager.createTableAsync(DdlToCatalogCommandConverter.convert((CreateTableCommand) cmd)) - .handle(handleModificationResult(((CreateTableCommand) cmd).ifTableExists(), TableAlreadyExistsException.class)); - } else if (cmd instanceof DropTableCommand) { - return tableManager.dropTableAsync(DdlToCatalogCommandConverter.convert((DropTableCommand) cmd)) - .handle(handleModificationResult(((DropTableCommand) cmd).ifTableExists(), TableNotFoundException.class)); - } else if (cmd instanceof AlterTableAddCommand) { - AlterTableAddCommand addCommand = (AlterTableAddCommand) cmd; - - return tableManager.alterTableAddColumnAsync(DdlToCatalogCommandConverter.convert(addCommand)) - .handle(handleModificationResult(addCommand.ifTableExists(), TableNotFoundException.class)); - } else if (cmd instanceof AlterTableDropCommand) { - AlterTableDropCommand dropCommand = (AlterTableDropCommand) cmd; - - return tableManager.alterTableDropColumnAsync(DdlToCatalogCommandConverter.convert(dropCommand)) - .handle(handleModificationResult(dropCommand.ifTableExists(), TableNotFoundException.class)); - } else if (cmd instanceof AlterColumnCommand) { - return catalogManager.alterColumn(DdlToCatalogCommandConverter.convert((AlterColumnCommand) cmd)) - .handle(handleModificationResult(((AlterColumnCommand) cmd).ifTableExists(), TableNotFoundException.class)); - } else if (cmd instanceof CreateIndexCommand) { - AbstractIndexCommandParams params = DdlToCatalogCommandConverter.convert((CreateIndexCommand) cmd); - - if (params instanceof CreateSortedIndexParams) { - return indexManager.createSortedIndexAsync((CreateSortedIndexParams) params) - .handle(handleModificationResult(((CreateIndexCommand) cmd).ifNotExists(), IndexAlreadyExistsException.class)); - } else if (params instanceof CreateHashIndexParams) { - return indexManager.createHashIndexAsync((CreateHashIndexParams) params) - .handle(handleModificationResult(((CreateIndexCommand) cmd).ifNotExists(), IndexAlreadyExistsException.class)); - } - - return failedFuture(new IgniteInternalCheckedException(UNSUPPORTED_DDL_OPERATION_ERR, "Unsupported DDL operation [" - + "cmdName=" + cmd.getClass().getSimpleName() + "]")); - } else if (cmd instanceof DropIndexCommand) { - return indexManager.dropIndexAsync(DdlToCatalogCommandConverter.convert((DropIndexCommand) cmd)) - .handle(handleModificationResult(((DropIndexCommand) cmd).ifNotExists(), IndexNotFoundException.class)); - } - - // Handle other commands in usual way. - return super.handle(cmd); - } -} diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerExceptionHandlingTest.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerExceptionHandlingTest.java index b9e810ecd0..26bf4c8f28 100644 --- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerExceptionHandlingTest.java +++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerExceptionHandlingTest.java @@ -125,7 +125,7 @@ public class DdlCommandHandlerExceptionHandlingTest extends IgniteAbstractTest { "node" ); - commandHandler = new DdlCommandHandler(distributionZoneManager, tableManager, indexManager, dataStorageManager); + commandHandler = new DdlCommandHandler(distributionZoneManager, tableManager, indexManager, dataStorageManager, catalogManager); } @AfterEach diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DistributionZoneDdlCommandHandlerTest.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DistributionZoneDdlCommandHandlerTest.java index 8b52467311..d0a057b241 100644 --- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DistributionZoneDdlCommandHandlerTest.java +++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DistributionZoneDdlCommandHandlerTest.java @@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Arrays; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicReference; +import org.apache.ignite.internal.catalog.CatalogManager; import org.apache.ignite.internal.distributionzones.DistributionZoneConfigurationParameters; import org.apache.ignite.internal.distributionzones.DistributionZoneManager; import org.apache.ignite.internal.index.IndexManager; @@ -65,6 +66,9 @@ public class DistributionZoneDdlCommandHandlerTest extends IgniteAbstractTest { @Mock private DataStorageManager dataStorageManager; + @Mock + private CatalogManager catalogManager; + /** DDL commands handler. */ private DdlCommandHandler commandHandler; @@ -79,7 +83,7 @@ public class DistributionZoneDdlCommandHandlerTest extends IgniteAbstractTest { return CompletableFuture.completedFuture(null); }); - commandHandler = new DdlCommandHandler(distributionZoneManager, tableManager, indexManager, dataStorageManager); + commandHandler = new DdlCommandHandler(distributionZoneManager, tableManager, indexManager, dataStorageManager, catalogManager); } 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 6a7b8b7721..e2e5ce1092 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 @@ -1478,25 +1478,6 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp ); } - /** - * Creates a new table with the given {@code name} asynchronously. If a table with the same name already exists, a future will be - * completed with {@link TableAlreadyExistsException}. - * - * @param name Table name. - * @param zoneName Distribution zone name. - * @param tableInitChange Table changer. - * @return Future representing pending completion of the operation. - * @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when: - * <ul> - * <li>the node is stopping.</li> - * </ul> - * @see TableAlreadyExistsException - */ - @Deprecated - public CompletableFuture<Table> createTableAsync(String name, String zoneName, Consumer<TableChange> tableInitChange) { - throw new UnsupportedOperationException("Method is no longer supported."); - } - /** * Creates a new table from parameters. * @@ -1504,7 +1485,6 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp * @return Future representing pending completion of the operation. * @see TableAlreadyExistsException */ - @Deprecated(forRemoval = true) public CompletableFuture<Table> createTableAsync(CreateTableParams parameters) { if (!busyLock.enterBusy()) { throw new IgniteException(new NodeStoppingException()); @@ -1713,7 +1693,6 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp * @return Future representing pending completion of the operation. * @see TableNotFoundException */ - @Deprecated public CompletableFuture<Void> alterTableAddColumnAsync(AlterTableAddColumnParams params) { if (!busyLock.enterBusy()) { throw new IgniteException(new NodeStoppingException()); @@ -1733,7 +1712,6 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp * @return Future representing pending completion of the operation. * @see TableNotFoundException */ - @Deprecated public CompletableFuture<Void> alterTableDropColumnAsync(AlterTableDropColumnParams params) { if (!busyLock.enterBusy()) { throw new IgniteException(new NodeStoppingException()); @@ -1824,23 +1802,6 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp return (ex instanceof IgniteException) ? (IgniteException) ex : IgniteExceptionUtils.wrap(ex); } - /** - * Drops a table with the name specified. If appropriate table does not be found, a future will be completed with - * {@link TableNotFoundException}. - * - * @param name Table name. - * @return Future representing pending completion of the operation. - * @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when: - * <ul> - * <li>the node is stopping.</li> - * </ul> - * @see TableNotFoundException - */ - @Deprecated(forRemoval = true) - public CompletableFuture<Void> dropTableAsync(String name) { - throw new UnsupportedOperationException("Method is no longer supported."); - } - /** * Drops a table with the name specified. If appropriate table does not be found, a future will be completed with * {@link TableNotFoundException}. @@ -1849,7 +1810,6 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp * @return Future representing pending completion of the operation. * @see TableNotFoundException */ - @Deprecated public CompletableFuture<Void> dropTableAsync(DropTableParams params) { if (!busyLock.enterBusy()) { throw new IgniteException(new NodeStoppingException()); @@ -1863,6 +1823,7 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp } /** See {@link #dropTableAsync(DropTableParams)} for details. */ + @Deprecated(forRemoval = true) private CompletableFuture<Void> dropTableAsyncInternal(String name) { return tableAsyncInternal(name).thenCompose(tbl -> { // In case of drop it's an optimization that allows not to fire drop-change-closure if there's no such