Skip to content

Commit

Permalink
Disabled some unsupportted operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Caideyipi authored Nov 29, 2024
1 parent 041d292 commit 45d189e
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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() {
Expand Down

0 comments on commit 45d189e

Please sign in to comment.