Search in sources :

Example 6 with HiveColumnQueryBean

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();
}
Also used : HiveColumnQueryBean(org.apache.inlong.manager.common.pojo.query.hive.HiveColumnQueryBean)

Aggregations

HiveColumnQueryBean (org.apache.inlong.manager.common.pojo.query.hive.HiveColumnQueryBean)6 ArrayList (java.util.ArrayList)4 HiveTableQueryBean (org.apache.inlong.manager.common.pojo.query.hive.HiveTableQueryBean)2 WorkflowException (org.apache.inlong.manager.common.exceptions.WorkflowException)1 ColumnInfoBean (org.apache.inlong.manager.common.pojo.query.ColumnInfoBean)1 HiveSinkDTO (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkDTO)1 StreamSinkFieldEntity (org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity)1