use of org.apache.inlong.manager.common.pojo.query.hive.HiveColumnQueryBean in project incubator-inlong by apache.
the class HiveChangeColumnBuilder method buildDDL.
@Override
public String buildDDL(HiveTableQueryBean table) {
// Support _ beginning with underscore
String dbTableName = "`" + table.getDbName() + "." + table.getTableName() + "`";
if (table.getColumns() == null || table.getColumns().size() == 0) {
return null;
}
ddl.append("ALTER TABLE ").append(dbTableName).append(" CHANGE COLUMN ");
HiveColumnQueryBean column = table.getColumns().get(0);
// Support _ beginning with underscore
String oldColumnName = "`" + column.getOldColumnName() + "`";
String columnName = "`" + column.getColumnName() + "`";
ddl.append(oldColumnName).append(" ").append(columnName).append(" ").append(column.getColumnType());
if (StringUtils.isNotEmpty(column.getColumnDesc())) {
ddl.append(" COMMENT ").append("'").append(column.getColumnDesc()).append("'");
}
return ddl.toString();
}
Aggregations