Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,26 @@ public void testCreateView() {
fail(e.getMessage());
}
}

@Test
public void testAddTimeColumn() {
try (final Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
statement.execute("use " + TABLE_DATABASE);

try {
statement.execute(
"create table table_time(device string tag, s1 int32 field, record_time timestamp time)");
statement.execute("alter table table_time add column d_datetime timestamp time");
fail("Add the TIME column should not be supported");
} catch (SQLException e) {
assertEquals("701: Adding TIME column is not supported.", e.getMessage());
}

} catch (SQLException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,9 @@ protected IConfigTask visitAddColumn(final AddColumn node, final MPPQueryContext
context.getSession().getUserName(), new QualifiedObjectName(database, tableName), context);

final ColumnDefinition definition = node.getColumn();
if (definition.getColumnCategory() == TsTableColumnCategory.TIME) {
throw new SemanticException("Adding TIME column is not supported.");
}
return new AlterTableAddColumnTask(
database,
tableName,
Expand Down
Loading