use of org.h2.command.ddl.AlterTableAlterColumn in project ignite by apache.
the class GridSqlQueryParser method parseAddColumn.
/**
* Parse {@code ALTER TABLE ... ADD COLUMN} statement.
* @param addCol H2 statement.
* @return Grid SQL statement.
*
* @see <a href="http://www.h2database.com/html/grammar.html#alter_table_add"></a>
*/
private GridSqlStatement parseAddColumn(AlterTableAlterColumn addCol) {
assert addCol.getType() == CommandInterface.ALTER_TABLE_ADD_COLUMN;
if (ALTER_COLUMN_BEFORE_COL.get(addCol) != null || ALTER_COLUMN_AFTER_COL.get(addCol) != null)
throw new IgniteSQLException("ALTER TABLE ADD COLUMN BEFORE/AFTER is not supported", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
GridSqlAlterTableAddColumn res = new GridSqlAlterTableAddColumn();
ArrayList<Column> h2NewCols = ALTER_COLUMN_NEW_COLS.get(addCol);
GridSqlColumn[] gridNewCols = new GridSqlColumn[h2NewCols.size()];
for (int i = 0; i < h2NewCols.size(); i++) {
Column col = h2NewCols.get(i);
if (col.getDefaultExpression() != null)
throw new IgniteSQLException("ALTER TABLE ADD COLUMN with DEFAULT value is not supported " + "[col=" + col.getName() + ']', IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
gridNewCols[i] = parseColumn(h2NewCols.get(i));
}
res.columns(gridNewCols);
if (gridNewCols.length == 1)
res.ifNotExists(ALTER_COLUMN_IF_NOT_EXISTS.get(addCol));
res.ifTableExists(ALTER_COLUMN_IF_TBL_EXISTS.get(addCol));
Schema schema = SCHEMA_COMMAND_SCHEMA.get(addCol);
res.schemaName(schema.getName());
res.tableName(ALTER_COLUMN_TBL_NAME.get(addCol));
return res;
}
use of org.h2.command.ddl.AlterTableAlterColumn in project ignite by apache.
the class GridSqlQueryParser method parseDropColumn.
/**
* Parse {@code ALTER TABLE ... DROP COLUMN} statement.
* @param dropCol H2 statement.
* @see <a href="http://www.h2database.com/html/grammar.html#alter_table_add"></a>
*/
private GridSqlStatement parseDropColumn(AlterTableAlterColumn dropCol) {
assert dropCol.getType() == CommandInterface.ALTER_TABLE_DROP_COLUMN;
GridSqlAlterTableDropColumn res = new GridSqlAlterTableDropColumn();
ArrayList<Column> h2DropCols = ALTER_COLUMN_REMOVE_COLS.get(dropCol);
String[] gridDropCols = new String[h2DropCols.size()];
for (int i = 0; i < h2DropCols.size(); i++) gridDropCols[i] = h2DropCols.get(i).getName();
res.columns(gridDropCols);
if (gridDropCols.length == 1)
res.ifExists(!ALTER_COLUMN_IF_NOT_EXISTS.get(dropCol));
res.ifTableExists(ALTER_COLUMN_IF_TBL_EXISTS.get(dropCol));
Schema schema = SCHEMA_COMMAND_SCHEMA.get(dropCol);
res.schemaName(schema.getName());
res.tableName(ALTER_COLUMN_TBL_NAME.get(dropCol));
return res;
}
Aggregations