use of org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError in project hive by apache.
the class TestConstraintsMerge method testUpdateInMergeViolatesCheckConstraint.
@Test
public void testUpdateInMergeViolatesCheckConstraint() throws Exception {
HiveConf confForTez = new HiveConf(hiveConf);
confForTez.setBoolVar(HiveConf.ConfVars.HIVE_EXPLAIN_USER, false);
setupTez(confForTez);
runStatementOnDriver("insert into " + Table.TBL_CHECK_MERGE + "(name, age, gpa) values " + "('student1', 16, 2.0)", confForTez);
Throwable error = null;
try {
runStatementOnDriver("merge into " + Table.TBL_CHECK_MERGE + " using (select age from table_source) source\n" + "on source.age=table_check_merge.age\n" + "when matched then update set gpa=6", confForTez);
} catch (Throwable t) {
error = t;
}
assertTrue(error instanceof DataConstraintViolationError);
assertTrue(error.getMessage().contains("Either CHECK or NOT NULL constraint violated!"));
}
use of org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError in project hive by apache.
the class TestGenericUDFEnforceConstraint method testNull.
@Test
public void testNull() throws HiveException {
try {
GenericUDFEnforceConstraint udf = new GenericUDFEnforceConstraint();
ObjectInspector valueOI = PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
ObjectInspector[] arguments = { valueOI };
udf.initialize(arguments);
BooleanWritable input = new BooleanWritable(false);
GenericUDF.DeferredObject[] args = { new GenericUDF.DeferredJavaObject(input) };
udf.evaluate(args);
fail("Unreachable line");
} catch (DataConstraintViolationError e) {
// DataConstraintViolationError is expected
assertTrue(e.getMessage().contains("NOT NULL constraint violated!"));
}
}
Aggregations