use of org.apache.hadoop.hive.ql.metadata.DefaultConstraint.DefaultConstraintCol in project hive by apache.
the class TextDescTableFormatter method getDefaultConstraintRelInformation.
private void getDefaultConstraintRelInformation(StringBuilder constraintsInfo, String constraintName, List<DefaultConstraintCol> columns) {
formatOutput("Constraint Name:", constraintName, constraintsInfo);
if (CollectionUtils.isNotEmpty(columns)) {
for (DefaultConstraintCol column : columns) {
String[] fields = new String[2];
fields[0] = "Column Name:" + column.colName;
fields[1] = "Default Value:" + column.defaultVal;
formatOutput(fields, constraintsInfo);
}
}
constraintsInfo.append(LINE_DELIM);
}
use of org.apache.hadoop.hive.ql.metadata.DefaultConstraint.DefaultConstraintCol in project hive by apache.
the class DDLPlanUtils method getAlterTableStmtDefaultConstraint.
public void getAlterTableStmtDefaultConstraint(DefaultConstraint dc, Table tb, List<String> constraints) {
if (!DefaultConstraint.isNotEmpty(dc)) {
return;
}
Map<String, String> colType = getTableColumnsToType(tb);
Map<String, List<DefaultConstraintCol>> defaultConstraints = dc.getDefaultConstraints();
for (String constraintName : defaultConstraints.keySet()) {
List<DefaultConstraintCol> defaultConstraintCols = defaultConstraints.get(constraintName);
for (DefaultConstraintCol col : defaultConstraintCols) {
ST command = new ST(ALTER_TABLE_ADD_DEFAULT_CONSTRAINT);
command.add(DATABASE_NAME, dc.getTableName());
command.add(TABLE_NAME, dc.getTableName());
command.add(COLUMN_NAME, col.colName);
command.add(COL_TYPE, colType.get(col.colName));
command.add(DEFAULT_VALUE, col.defaultVal);
command.add(ENABLE, col.enable);
command.add(VALIDATE, col.validate);
command.add(RELY, col.rely);
constraints.add(command.render());
}
}
}
Aggregations