Search in sources :

Example 1 with CheckConstraintCol

use of org.apache.hadoop.hive.ql.metadata.CheckConstraint.CheckConstraintCol in project hive by apache.

the class TextDescTableFormatter method getCheckConstraintRelInformation.

private void getCheckConstraintRelInformation(StringBuilder constraintsInfo, String constraintName, List<CheckConstraintCol> columns) {
    formatOutput("Constraint Name:", constraintName, constraintsInfo);
    if (CollectionUtils.isNotEmpty(columns)) {
        for (CheckConstraintCol column : columns) {
            String[] fields = new String[2];
            fields[0] = "Column Name:" + column.getColName();
            fields[1] = "Check Value:" + column.getCheckExpression();
            formatOutput(fields, constraintsInfo);
        }
    }
    constraintsInfo.append(LINE_DELIM);
}
Also used : CheckConstraintCol(org.apache.hadoop.hive.ql.metadata.CheckConstraint.CheckConstraintCol)

Example 2 with CheckConstraintCol

use of org.apache.hadoop.hive.ql.metadata.CheckConstraint.CheckConstraintCol in project hive by apache.

the class DDLPlanUtils method getAlterTableStmtCheckConstraint.

public void getAlterTableStmtCheckConstraint(CheckConstraint ck, List<String> constraints) {
    if (!CheckConstraint.isNotEmpty(ck)) {
        return;
    }
    Map<String, List<CheckConstraint.CheckConstraintCol>> checkConstraints = ck.getCheckConstraints();
    for (String constraintName : checkConstraints.keySet()) {
        List<CheckConstraintCol> checkConstraintCols = checkConstraints.get(constraintName);
        if (checkConstraintCols != null && checkConstraintCols.size() > 0) {
            for (CheckConstraintCol col : checkConstraintCols) {
                ST command = new ST(ALTER_TABLE_ADD_CHECK_CONSTRAINT);
                command.add(DATABASE_NAME, ck.getDatabaseName());
                command.add(TABLE_NAME, ck.getTableName());
                command.add(CONSTRAINT_NAME, constraintName);
                command.add(CHECK_EXPRESSION, col.getCheckExpression());
                command.add(ENABLE, col.getEnable());
                command.add(VALIDATE, col.getValidate());
                command.add(RELY, col.getRely());
                constraints.add(command.render());
            }
        }
    }
}
Also used : ST(org.stringtemplate.v4.ST) CheckConstraintCol(org.apache.hadoop.hive.ql.metadata.CheckConstraint.CheckConstraintCol) List(java.util.List) ArrayList(java.util.ArrayList) CheckConstraint(org.apache.hadoop.hive.ql.metadata.CheckConstraint)

Aggregations

CheckConstraintCol (org.apache.hadoop.hive.ql.metadata.CheckConstraint.CheckConstraintCol)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CheckConstraint (org.apache.hadoop.hive.ql.metadata.CheckConstraint)1 ST (org.stringtemplate.v4.ST)1