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 808d4cbdfbca..e7ac5eef74cb 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 @@ -247,18 +247,21 @@ public void testDevice() throws SQLException { TestUtils.assertResultSetSize( statement.executeQuery("show devices from table0 offset 1 limit 1"), 1); - // Test delete devices - statement.execute("delete devices from table0 where region_id = '1' and plant_id = '5'"); - TestUtils.assertResultSetSize(statement.executeQuery("show devices from table0"), 1); + // TODO: Reopen + if (false) { + // Test delete devices + statement.execute("delete devices from table0 where region_id = '1' and plant_id = '5'"); + 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', '5', '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', '5', '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); + } } } } 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 251dd81f2389..981c1c7b22a7 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 @@ -385,66 +385,69 @@ public void testManageTable() { statement.execute( "insert into table2(region_id, plant_id, color, temperature, speed) values(1, 1, 1, 1, 1)"); - // 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", "ID", "ID", "MEASUREMENT", "MEASUREMENT"}; - 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++; + // 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", "ID", "ID", "MEASUREMENT", "MEASUREMENT"}; + 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); } - assertEquals(columnNames.length, cnt); - } - statement.execute("alter table table2 drop column speed"); + 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()); - } + try { + statement.executeQuery("select color from table2"); + fail(); + } catch (final SQLException e) { + assertEquals("701: Column 'color' cannot be resolved", e.getMessage()); + } - try { - statement.executeQuery("select speed from table2"); - fail(); - } catch (final SQLException e) { - assertEquals("701: Column 'speed' cannot be resolved", e.getMessage()); - } + try { + statement.executeQuery("select speed from table2"); + fail(); + } catch (final SQLException e) { + assertEquals("701: Column 'speed' cannot be resolved", e.getMessage()); + } - 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 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 id or time column is not supported.", e.getMessage()); - } + try { + statement.execute("alter table table2 drop column time"); + } catch (final SQLException e) { + assertEquals("701: Dropping id 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,")); + // 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 { @@ -496,11 +499,14 @@ public void testManageTable() { 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()); + // 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 { 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 c331b2306ed0..caadbf31b753 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 @@ -22,6 +22,7 @@ import org.apache.iotdb.commons.path.PartialPath; 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.common.header.ColumnHeader; import org.apache.iotdb.db.queryengine.execution.operator.schema.source.DeviceBlackListConstructor; @@ -67,6 +68,7 @@ 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 bd776614ab7a..1cad3f8f3a3c 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,6 +19,8 @@ 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; @@ -35,18 +37,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, @@ -58,6 +48,7 @@ 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() {