From 582555509bbd02aa66e6f65f20c57de34c133c09 Mon Sep 17 00:00:00 2001 From: Caideyipi <87789683+Caideyipi@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:56:40 +0800 Subject: [PATCH 1/4] reopen --- .../relational/it/schema/IoTDBDeviceIT.java | 37 +++--- .../relational/it/schema/IoTDBTableIT.java | 122 +++++++++--------- .../plan/relational/sql/ast/DeleteDevice.java | 2 - .../plan/relational/sql/ast/DropColumn.java | 15 ++- 4 files changed, 87 insertions(+), 89 deletions(-) diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java index a7c6f5f3dd94..4652c78fec3b 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java @@ -249,29 +249,26 @@ public void testDevice() throws SQLException { TestUtils.assertResultSetSize( statement.executeQuery("show devices from table0 offset 1 limit 1"), 1); - // TODO: Reopen - if (false) { - // Test delete devices - statement.execute("delete devices from table0 where region_id = '1' and plant_id = '木兰'"); - TestUtils.assertResultSetSize(statement.executeQuery("show devices from table0"), 1); + // Test delete devices + statement.execute("delete devices from table0 where region_id = '1' and plant_id = '木兰'"); + TestUtils.assertResultSetSize(statement.executeQuery("show devices from table0"), 1); - // Test successfully Invalidate cache - statement.execute( - "insert into table0(region_id, plant_id, device_id, model, temperature, humidity) values('1', '木兰', '3', 'A', 37.6, 111.1)"); - TestUtils.assertResultSetSize(statement.executeQuery("show devices from table0"), 2); + // Test successfully Invalidate cache + statement.execute( + "insert into table0(region_id, plant_id, device_id, model, temperature, humidity) values('1', '木兰', '3', 'A', 37.6, 111.1)"); + TestUtils.assertResultSetSize(statement.executeQuery("show devices from table0"), 2); - // Test successfully delete data - TestUtils.assertResultSetSize( - statement.executeQuery("select * from table0 where region_id = '1'"), 1); + // Test successfully delete data + TestUtils.assertResultSetSize( + statement.executeQuery("select * from table0 where region_id = '1'"), 1); - try { - statement.executeQuery("delete devices from table0 where time = 1"); - fail("Delete devices shall fail when specifies non tag column"); - } catch (final Exception e) { - assertEquals( - "701: The TIME/FIELD columns are currently not allowed in devices related operations", - e.getMessage()); - } + try { + statement.executeQuery("delete devices from table0 where time = 1"); + fail("Delete devices shall fail when specifies non tag column"); + } catch (final Exception e) { + assertEquals( + "701: The TIME/FIELD columns are currently not allowed in devices related operations", + e.getMessage()); } } } diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java index 2def42f0dcc6..f730a21c22b5 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java @@ -390,70 +390,67 @@ public void testManageTable() { statement.execute( "insert into table2(region_id, plant_id, color, temperature, speed) values(1, 1, 1, 1, 1)"); - // TODO: Reopen - if (false) { - // Test drop column - statement.execute("alter table table2 drop column color"); - - columnNames = new String[] {"time", "region_id", "plant_id", "temperature", "speed"}; - dataTypes = new String[] {"TIMESTAMP", "STRING", "STRING", "FLOAT", "DOUBLE"}; - categories = new String[] {"TIME", "TAG", "TAG", "FIELD", "FIELD"}; - final String[] statuses = new String[] {"USING", "USING", "USING", "USING", "USING"}; - try (final ResultSet resultSet = statement.executeQuery("describe table2 details")) { - int cnt = 0; - ResultSetMetaData metaData = resultSet.getMetaData(); - assertEquals(describeTableDetailsColumnHeaders.size(), metaData.getColumnCount()); - for (int i = 0; i < describeTableDetailsColumnHeaders.size(); i++) { - assertEquals( - describeTableDetailsColumnHeaders.get(i).getColumnName(), - metaData.getColumnName(i + 1)); - } - while (resultSet.next()) { - assertEquals(columnNames[cnt], resultSet.getString(1)); - assertEquals(dataTypes[cnt], resultSet.getString(2)); - assertEquals(categories[cnt], resultSet.getString(3)); - assertEquals(statuses[cnt], resultSet.getString(4)); - cnt++; - } - assertEquals(columnNames.length, cnt); + // Test drop column + statement.execute("alter table table2 drop column color"); + + columnNames = new String[] {"time", "region_id", "plant_id", "temperature", "speed"}; + dataTypes = new String[] {"TIMESTAMP", "STRING", "STRING", "FLOAT", "DOUBLE"}; + categories = new String[] {"TIME", "TAG", "TAG", "FIELD", "FIELD"}; + final String[] statuses = new String[] {"USING", "USING", "USING", "USING", "USING"}; + try (final ResultSet resultSet = statement.executeQuery("describe table2 details")) { + int cnt = 0; + ResultSetMetaData metaData = resultSet.getMetaData(); + assertEquals(describeTableDetailsColumnHeaders.size(), metaData.getColumnCount()); + for (int i = 0; i < describeTableDetailsColumnHeaders.size(); i++) { + assertEquals( + describeTableDetailsColumnHeaders.get(i).getColumnName(), + metaData.getColumnName(i + 1)); } - - statement.execute("alter table table2 drop column speed"); - - try { - statement.executeQuery("select color from table2"); - fail(); - } catch (final SQLException e) { - assertEquals("701: Column 'color' cannot be resolved", e.getMessage()); + while (resultSet.next()) { + assertEquals(columnNames[cnt], resultSet.getString(1)); + assertEquals(dataTypes[cnt], resultSet.getString(2)); + assertEquals(categories[cnt], resultSet.getString(3)); + assertEquals(statuses[cnt], resultSet.getString(4)); + cnt++; } + assertEquals(columnNames.length, cnt); + } - try { - statement.executeQuery("select speed from table2"); - fail(); - } catch (final SQLException e) { - assertEquals("701: Column 'speed' cannot be resolved", e.getMessage()); - } + statement.execute("alter table table2 drop column speed"); - try { - statement.execute("alter table table2 drop column speed"); - } catch (final SQLException e) { - assertEquals("616: Column speed in table 'test2.table2' does not exist.", e.getMessage()); - } + try { + statement.executeQuery("select color from table2"); + fail(); + } catch (final SQLException e) { + assertEquals("701: Column 'color' cannot be resolved", e.getMessage()); + } - try { - statement.execute("alter table table2 drop column time"); - } catch (final SQLException e) { - assertEquals("701: Dropping tag or time column is not supported.", e.getMessage()); - } + try { + statement.executeQuery("select speed from table2"); + fail(); + } catch (final SQLException e) { + assertEquals("701: Column 'speed' cannot be resolved", e.getMessage()); + } - // test data deletion by drop column - statement.execute("alter table table2 add column speed double"); - TestUtils.assertResultSetEqual( - statement.executeQuery("select speed from table2"), - "speed,", - Collections.singleton("null,")); + try { + statement.execute("alter table table2 drop column speed"); + } catch (final SQLException e) { + assertEquals("616: Column speed in table 'test2.table2' does not exist.", e.getMessage()); } + try { + statement.execute("alter table table2 drop column time"); + } catch (final SQLException e) { + assertEquals("701: Dropping tag or time column is not supported.", e.getMessage()); + } + + // test data deletion by drop column + statement.execute("alter table table2 add column speed double"); + TestUtils.assertResultSetEqual( + statement.executeQuery("select speed from table2"), + "speed,", + Collections.singleton("null,")); + statement.execute("drop table table2"); try { statement.executeQuery("describe table2"); @@ -504,14 +501,11 @@ public void testManageTable() { assertEquals("500: Unknown database test1", e.getMessage()); } - // TODO: Reopen - if (false) { - try { - statement.execute("alter table test1.test drop column a"); - fail(); - } catch (final SQLException e) { - assertEquals("500: Unknown database test1", e.getMessage()); - } + try { + statement.execute("alter table test1.test drop column a"); + fail(); + } catch (final SQLException e) { + assertEquals("500: Unknown database test1", e.getMessage()); } try { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DeleteDevice.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DeleteDevice.java index 79bf8147da35..6d3f3438f087 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DeleteDevice.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DeleteDevice.java @@ -23,7 +23,6 @@ import org.apache.iotdb.commons.schema.column.ColumnHeader; import org.apache.iotdb.commons.schema.filter.SchemaFilter; import org.apache.iotdb.commons.schema.table.TsTable; -import org.apache.iotdb.db.exception.sql.SemanticException; import org.apache.iotdb.db.queryengine.common.SessionInfo; import org.apache.iotdb.db.queryengine.execution.operator.schema.source.DeviceBlackListConstructor; import org.apache.iotdb.db.queryengine.execution.operator.schema.source.TableDeviceQuerySource; @@ -68,7 +67,6 @@ public class DeleteDevice extends AbstractTraverseDevice { public DeleteDevice(final NodeLocation location, final Table table, final Expression where) { super(location, table, where); - throw new SemanticException("Delete device is unsupported yet."); } public void parseModEntries(final TsTable table) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DropColumn.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DropColumn.java index 1cad3f8f3a3c..bd776614ab7a 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DropColumn.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DropColumn.java @@ -19,8 +19,6 @@ package org.apache.iotdb.db.queryengine.plan.relational.sql.ast; -import org.apache.iotdb.db.exception.sql.SemanticException; - import com.google.common.collect.ImmutableList; import java.util.List; @@ -37,6 +35,18 @@ public class DropColumn extends Statement { private final boolean tableIfExists; private final boolean columnIfExists; + public DropColumn( + final QualifiedName table, + final Identifier field, + final boolean tableIfExists, + final boolean columnIfExists) { + super(null); + this.table = requireNonNull(table, "table is null"); + this.field = requireNonNull(field, "field is null"); + this.tableIfExists = tableIfExists; + this.columnIfExists = columnIfExists; + } + public DropColumn( final NodeLocation location, final QualifiedName table, @@ -48,7 +58,6 @@ public DropColumn( this.field = requireNonNull(field, "field is null"); this.tableIfExists = tableIfExists; this.columnIfExists = columnIfExists; - throw new SemanticException("Drop column is unsupported yet."); } public QualifiedName getTable() { From d7934093abe9d7013dcdc4fb05a0b54ea2079c62 Mon Sep 17 00:00:00 2001 From: Caideyipi <87789683+Caideyipi@users.noreply.github.com> Date: Tue, 7 Jan 2025 18:17:08 +0800 Subject: [PATCH 2/4] Update ConfigMTree.java --- .../apache/iotdb/confignode/persistence/schema/ConfigMTree.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java index bb6474258bd0..f02a854f48c5 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java @@ -850,7 +850,7 @@ public boolean preDeleteColumn( } if (columnSchema.getColumnCategory() == TsTableColumnCategory.TAG || columnSchema.getColumnCategory() == TsTableColumnCategory.TIME) { - throw new SemanticException("Dropping id or time column is not supported."); + throw new SemanticException("Dropping tag or time column is not supported."); } node.addPreDeletedColumn(columnName); From fe7f83d0b314ddeed8cf39c57ad1fbe3ea3b0a51 Mon Sep 17 00:00:00 2001 From: Caideyipi <87789683+Caideyipi@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:26:56 +0800 Subject: [PATCH 3/4] Update DropColumn.java --- .../plan/relational/sql/ast/DropColumn.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DropColumn.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DropColumn.java index bd776614ab7a..20e180530889 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DropColumn.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DropColumn.java @@ -35,18 +35,6 @@ public class DropColumn extends Statement { private final boolean tableIfExists; private final boolean columnIfExists; - public DropColumn( - final QualifiedName table, - final Identifier field, - final boolean tableIfExists, - final boolean columnIfExists) { - super(null); - this.table = requireNonNull(table, "table is null"); - this.field = requireNonNull(field, "field is null"); - this.tableIfExists = tableIfExists; - this.columnIfExists = columnIfExists; - } - public DropColumn( final NodeLocation location, final QualifiedName table, From 6f22f1352b68c10430d9a126e8d41e3d2b11b0f2 Mon Sep 17 00:00:00 2001 From: Caideyipi <87789683+Caideyipi@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:40:41 +0800 Subject: [PATCH 4/4] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28f72ddc9bcc..e278d579b445 100644 --- a/pom.xml +++ b/pom.xml @@ -167,7 +167,7 @@ 0.14.1 1.9 1.5.6-3 - 1.2.0-241224-SNAPSHOT + 2.0.0-250109-SNAPSHOT