You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2023/06/02 11:04:56 UTC
[ignite-3] 01/01: Drop dead code.
This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch ignite-19611
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit f421aa32d1fa5300b52fb8f119829a4f0a55368d
Author: amashenkov <an...@gmail.com>
AuthorDate: Fri Jun 2 14:04:47 2023 +0300
Drop dead code.
---
.../commands/AbstractTableCommandParams.java | 22 ----
.../internal/catalog/CatalogServiceSelfTest.java | 112 ++++-----------------
.../exec/ddl/DdlToCatalogCommandConverter.java | 4 -
3 files changed, 17 insertions(+), 121 deletions(-)
diff --git a/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/AbstractTableCommandParams.java b/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/AbstractTableCommandParams.java
index a459d2835c..67c7a588e8 100644
--- a/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/AbstractTableCommandParams.java
+++ b/modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/AbstractTableCommandParams.java
@@ -24,9 +24,6 @@ public class AbstractTableCommandParams implements DdlCommandParams {
/** Table name. */
protected String tableName;
- /** Quietly ignore this command if table is not exists. */
- protected boolean ifTableExists;
-
/** Schema name where this new table will be created. */
protected String schema;
@@ -44,13 +41,6 @@ public class AbstractTableCommandParams implements DdlCommandParams {
return schema;
}
- /**
- * Quietly ignore if table is not exist.
- */
- public boolean ifTableExists() {
- return ifTableExists;
- }
-
/**
* Parameters builder.
*/
@@ -83,18 +73,6 @@ public class AbstractTableCommandParams implements DdlCommandParams {
return (BuilderT) this;
}
- /**
- * Set quietly ignore flag.
- *
- * @param ifTableNotExists Flag.
- * @return {@code this}.
- */
- public BuilderT ifTableExists(boolean ifTableNotExists) {
- params.ifTableExists = ifTableNotExists;
-
- return (BuilderT) this;
- }
-
/**
* Builds parameters.
*
diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogServiceSelfTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogServiceSelfTest.java
index affc600d87..3e0589ef77 100644
--- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogServiceSelfTest.java
+++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogServiceSelfTest.java
@@ -159,7 +159,6 @@ public class CatalogServiceSelfTest {
CreateTableParams params = CreateTableParams.builder()
.schemaName(SCHEMA_NAME)
.tableName(TABLE_NAME)
- .ifTableExists(true)
.zone(ZONE_NAME)
.columns(List.of(
ColumnParams.builder().name("key1").type(ColumnType.INT32).build(),
@@ -209,9 +208,7 @@ public class CatalogServiceSelfTest {
assertEquals(0L, table.zoneId());
// Validate another table creation.
- fut = service.createTable(simpleTable(TABLE_NAME_2));
-
- assertThat(fut, willBe((Object) null));
+ assertThat(service.createTable(simpleTable(TABLE_NAME_2)), willBe((Object) null));
// Validate actual catalog has both tables.
schema = service.schema(2);
@@ -229,35 +226,12 @@ public class CatalogServiceSelfTest {
assertSame(schema.table(TABLE_NAME_2), service.table(2, System.currentTimeMillis()));
assertNotSame(schema.table(TABLE_NAME), schema.table(TABLE_NAME_2));
- }
- @Test
- public void testCreateTableIfExistsFlag() {
- CreateTableParams params = CreateTableParams.builder()
- .tableName(TABLE_NAME)
- .columns(List.of(
- ColumnParams.builder().name("key").type(ColumnType.INT32).build(),
- ColumnParams.builder().name("val").type(ColumnType.INT32).build()
- ))
- .primaryKeyColumns(List.of("key"))
- .ifTableExists(true)
- .build();
+ // Try to create another table with same name.
+ assertThat(service.createTable(simpleTable(TABLE_NAME_2)), willThrowFast(TableAlreadyExistsException.class));
- assertThat(service.createTable(params), willBe((Object) null));
- assertThat(service.createTable(params), willThrowFast(TableAlreadyExistsException.class));
-
- CompletableFuture<?> fut = service.createTable(
- CreateTableParams.builder()
- .tableName(TABLE_NAME)
- .columns(List.of(
- ColumnParams.builder().name("key").type(ColumnType.INT32).build(),
- ColumnParams.builder().name("val").type(ColumnType.INT32).build()
- ))
- .primaryKeyColumns(List.of("key"))
- .ifTableExists(false)
- .build());
-
- assertThat(fut, willThrowFast(TableAlreadyExistsException.class));
+ // Validate schema wasn't changed.
+ assertSame(schema, service.activeSchema(System.currentTimeMillis()));
}
@Test
@@ -303,38 +277,12 @@ public class CatalogServiceSelfTest {
assertSame(schema.table(TABLE_NAME_2), service.table(TABLE_NAME_2, System.currentTimeMillis()));
assertSame(schema.table(TABLE_NAME_2), service.table(2, System.currentTimeMillis()));
- }
-
- @Test
- public void testDropTableIfExistsFlag() {
- CreateTableParams createTableParams = CreateTableParams.builder()
- .schemaName(SCHEMA_NAME)
- .tableName(TABLE_NAME)
- .columns(List.of(
- ColumnParams.builder().name("key").type(ColumnType.INT32).build(),
- ColumnParams.builder().name("val").type(ColumnType.INT32).build()
- ))
- .primaryKeyColumns(List.of("key"))
- .build();
-
- assertThat(service.createTable(createTableParams), willBe((Object) null));
-
- DropTableParams params = DropTableParams.builder()
- .schemaName(SCHEMA_NAME)
- .tableName(TABLE_NAME)
- .ifTableExists(true)
- .build();
-
- assertThat(service.dropTable(params), willBe((Object) null));
- assertThat(service.dropTable(params), willThrowFast(TableNotFoundException.class));
- params = DropTableParams.builder()
- .schemaName(SCHEMA_NAME)
- .tableName(TABLE_NAME)
- .ifTableExists(false)
- .build();
+ // Try to drop table once again.
+ assertThat(service.dropTable(dropTableParams), willThrowFast(TableNotFoundException.class));
- assertThat(service.dropTable(params), willThrowFast(TableNotFoundException.class));
+ // Validate schema wasn't changed.
+ assertSame(schema, service.activeSchema(System.currentTimeMillis()));
}
@Test
@@ -419,26 +367,26 @@ public class CatalogServiceSelfTest {
}
@Test
- public void testDropColumnIfTableExistsFlag() {
+ public void testCreateDropColumnIfTableNotExists() {
assertNull(service.table(TABLE_NAME, System.currentTimeMillis()));
- AlterTableAddColumnParams params = AlterTableAddColumnParams.builder()
+ // Try to add a new column.
+ AlterTableAddColumnParams addColumnParams = AlterTableAddColumnParams.builder()
.schemaName(SCHEMA_NAME)
.tableName(TABLE_NAME)
.columns(List.of(ColumnParams.builder().name(NEW_COLUMN_NAME).type(ColumnType.INT32).nullable(true).build()))
- .ifTableExists(false)
.build();
- assertThat(service.addColumn(params), willThrow(TableNotFoundException.class));
+ assertThat(service.addColumn(addColumnParams), willThrow(TableNotFoundException.class));
- params = AlterTableAddColumnParams.builder()
+ // Try to drop column.
+ AlterTableDropColumnParams dropColumnParams = AlterTableDropColumnParams.builder()
.schemaName(SCHEMA_NAME)
.tableName(TABLE_NAME)
- .columns(List.of(ColumnParams.builder().name(NEW_COLUMN_NAME).type(ColumnType.INT32).nullable(true).build()))
- .ifTableExists(true)
+ .columns(Set.of("VAL"))
.build();
- assertThat(service.addColumn(params), willThrow(TableNotFoundException.class));
+ assertThat(service.dropColumn(dropColumnParams), willThrow(TableNotFoundException.class));
}
@Test
@@ -474,29 +422,6 @@ public class CatalogServiceSelfTest {
assertNotNull(schema.table(TABLE_NAME).column("VAL"));
}
- @Test
- public void testAddColumnIfTableExistsFlag() {
- assertNull(service.table(TABLE_NAME, System.currentTimeMillis()));
-
- AlterTableAddColumnParams params = AlterTableAddColumnParams.builder()
- .schemaName(SCHEMA_NAME)
- .tableName(TABLE_NAME)
- .columns(List.of(ColumnParams.builder().name(NEW_COLUMN_NAME).type(ColumnType.INT32).nullable(true).build()))
- .ifTableExists(false)
- .build();
-
- assertThat(service.addColumn(params), willThrow(TableNotFoundException.class));
-
- params = AlterTableAddColumnParams.builder()
- .schemaName(SCHEMA_NAME)
- .tableName(TABLE_NAME)
- .columns(List.of(ColumnParams.builder().name(NEW_COLUMN_NAME).type(ColumnType.INT32).nullable(true).build()))
- .ifTableExists(true)
- .build();
-
- assertThat(service.addColumn(params), willThrow(TableNotFoundException.class));
- }
-
@Test
public void testAddDropMultipleColumns() {
assertThat(service.createTable(simpleTable(TABLE_NAME)), willBe((Object) null));
@@ -770,7 +695,6 @@ public class CatalogServiceSelfTest {
CreateTableParams createTableParams = CreateTableParams.builder()
.schemaName(SCHEMA_NAME)
.tableName(TABLE_NAME)
- .ifTableExists(true)
.zone(ZONE_NAME)
.columns(List.of(
ColumnParams.builder().name("key1").type(ColumnType.INT32).build(),
@@ -803,7 +727,6 @@ public class CatalogServiceSelfTest {
CreateTableParams createTableParams = CreateTableParams.builder()
.schemaName(CatalogService.PUBLIC)
.tableName(TABLE_NAME)
- .ifTableExists(true)
.zone("ZONE")
.columns(List.of(
ColumnParams.builder().name("key1").type(ColumnType.INT32).build(),
@@ -867,7 +790,6 @@ public class CatalogServiceSelfTest {
.nullable(true)
.build()
))
- .ifTableExists(true)
.build();
AlterTableDropColumnParams dropColumnParams = AlterTableDropColumnParams.builder()
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlToCatalogCommandConverter.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlToCatalogCommandConverter.java
index 738424d898..f7c4d5f211 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlToCatalogCommandConverter.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlToCatalogCommandConverter.java
@@ -51,7 +51,6 @@ class DdlToCatalogCommandConverter {
return CreateTableParams.builder()
.schemaName(cmd.schemaName())
.tableName(cmd.tableName())
- .ifTableExists(cmd.ifTableExists())
.columns(columns)
.colocationColumns(cmd.colocationColumns())
@@ -66,7 +65,6 @@ class DdlToCatalogCommandConverter {
return DropTableParams.builder()
.schemaName(cmd.schemaName())
.tableName(cmd.tableName())
- .ifTableExists(cmd.ifTableExists())
.build();
}
@@ -76,7 +74,6 @@ class DdlToCatalogCommandConverter {
return AlterTableAddColumnParams.builder()
.schemaName(cmd.schemaName())
.tableName(cmd.tableName())
- .ifTableExists(cmd.ifTableExists())
.columns(columns)
@@ -87,7 +84,6 @@ class DdlToCatalogCommandConverter {
return AlterTableDropColumnParams.builder()
.schemaName(cmd.schemaName())
.tableName(cmd.tableName())
- .ifTableExists(cmd.ifTableExists())
.columns(cmd.columns())