diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java index bb91eeae4b..26c759bdd5 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java @@ -214,7 +214,7 @@ system.registerUDF("rand", UDFRand.class, false); system.registerGenericUDF("abs", GenericUDFAbs.class); system.registerGenericUDF("sq_count_check", GenericUDFSQCountCheck.class); - system.registerGenericUDF("enforce_constraint", GenericUDFEnforceNotNullConstraint.class); + system.registerGenericUDF("enforce_constraint", GenericUDFEnforceConstraint.class); system.registerGenericUDF("pmod", GenericUDFPosMod.class); system.registerUDF("ln", UDFLn.class, false); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFEnforceNotNullConstraint.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFEnforceConstraint.java similarity index 92% rename from ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFEnforceNotNullConstraint.java rename to ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFEnforceConstraint.java index 6c8c6fdae3..aa0059b1cf 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFEnforceNotNullConstraint.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFEnforceConstraint.java @@ -33,9 +33,9 @@ * */ @Description(name = "enforce_constraint", - value = "_FUNC_(x) - Internal UDF to enforce NOT NULL constraint", + value = "_FUNC_(x) - Internal UDF to enforce CHECK and NOT NULL constraint", extended = "For internal use only") -public class GenericUDFEnforceNotNullConstraint extends GenericUDF { +public class GenericUDFEnforceConstraint extends GenericUDF { private final BooleanWritable resultBool = new BooleanWritable(); private transient BooleanObjectInspector boi; @@ -59,7 +59,7 @@ public Object evaluate(DeferredObject[] arguments) throws HiveException { if(!result) { throw new DataConstraintViolationError( - "NOT NULL constraint violated!"); + "Either CHECK or NOT NULL constraint violated!"); } resultBool.set(true); return resultBool; diff --git a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFEnforceNotNullConstraint.java b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFEnforceConstraint.java similarity index 88% rename from ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFEnforceNotNullConstraint.java rename to ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFEnforceConstraint.java index fc65bb6e62..a0da723e41 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFEnforceNotNullConstraint.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFEnforceConstraint.java @@ -26,13 +26,13 @@ import org.apache.hadoop.io.BooleanWritable; /** - * Test class for {@link GenericUDFEnforceNotNullConstraint}. + * Test class for {@link GenericUDFEnforceConstraint}. */ -public class TestGenericUDFEnforceNotNullConstraint extends TestCase { +public class TestGenericUDFEnforceConstraint extends TestCase { public void testNull() throws HiveException { try { - GenericUDFEnforceNotNullConstraint udf = new GenericUDFEnforceNotNullConstraint(); + GenericUDFEnforceConstraint udf = new GenericUDFEnforceConstraint(); ObjectInspector valueOI = PrimitiveObjectInspectorFactory.writableBooleanObjectInspector; ObjectInspector[] arguments = {valueOI }; udf.initialize(arguments); @@ -49,7 +49,7 @@ public void testNull() throws HiveException { public void testInvalidArgumentsLength() throws HiveException { try { - GenericUDFEnforceNotNullConstraint udf = new GenericUDFEnforceNotNullConstraint(); + GenericUDFEnforceConstraint udf = new GenericUDFEnforceConstraint(); ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableBooleanObjectInspector; ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableBooleanObjectInspector; ObjectInspector[] arguments = {valueOI1, valueOI2 }; @@ -62,7 +62,7 @@ public void testInvalidArgumentsLength() throws HiveException { } public void testCorrect() throws HiveException { - GenericUDFEnforceNotNullConstraint udf = new GenericUDFEnforceNotNullConstraint(); + GenericUDFEnforceConstraint udf = new GenericUDFEnforceConstraint(); ObjectInspector valueOI = PrimitiveObjectInspectorFactory.writableBooleanObjectInspector; ObjectInspector[] arguments = {valueOI }; udf.initialize(arguments); diff --git a/ql/src/test/results/clientnegative/alter_notnull_constraint_violation.q.out b/ql/src/test/results/clientnegative/alter_notnull_constraint_violation.q.out index 65195dc55b..2445b5de7f 100644 --- a/ql/src/test/results/clientnegative/alter_notnull_constraint_violation.q.out +++ b/ql/src/test/results/clientnegative/alter_notnull_constraint_violation.q.out @@ -24,4 +24,4 @@ POSTHOOK: query: alter table t1 change j j int constraint nn0 not null enforced POSTHOOK: type: ALTERTABLE_RENAMECOL POSTHOOK: Input: default@t1 POSTHOOK: Output: default@t1 -FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: NOT NULL constraint violated! +FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: Either CHECK or NOT NULL constraint violated! diff --git a/ql/src/test/results/clientnegative/insert_into_acid_notnull.q.out b/ql/src/test/results/clientnegative/insert_into_acid_notnull.q.out index 172c93355f..777a087878 100644 --- a/ql/src/test/results/clientnegative/insert_into_acid_notnull.q.out +++ b/ql/src/test/results/clientnegative/insert_into_acid_notnull.q.out @@ -10,4 +10,4 @@ POSTHOOK: query: create table acid_uami(i int, POSTHOOK: type: CREATETABLE POSTHOOK: Output: database:default POSTHOOK: Output: default@acid_uami -FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: NOT NULL constraint violated! +FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: Either CHECK or NOT NULL constraint violated! diff --git a/ql/src/test/results/clientnegative/insert_into_notnull_constraint.q.out b/ql/src/test/results/clientnegative/insert_into_notnull_constraint.q.out index dd720fad75..96feec0d30 100644 --- a/ql/src/test/results/clientnegative/insert_into_notnull_constraint.q.out +++ b/ql/src/test/results/clientnegative/insert_into_notnull_constraint.q.out @@ -6,4 +6,4 @@ POSTHOOK: query: create table nullConstraintCheck(i int NOT NULL enforced, j int POSTHOOK: type: CREATETABLE POSTHOOK: Output: database:default POSTHOOK: Output: default@nullConstraintCheck -FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: NOT NULL constraint violated! +FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: Either CHECK or NOT NULL constraint violated! diff --git a/ql/src/test/results/clientnegative/insert_multi_into_notnull.q.out b/ql/src/test/results/clientnegative/insert_multi_into_notnull.q.out index 1beeb26f95..74e112f6cd 100644 --- a/ql/src/test/results/clientnegative/insert_multi_into_notnull.q.out +++ b/ql/src/test/results/clientnegative/insert_multi_into_notnull.q.out @@ -14,4 +14,4 @@ POSTHOOK: query: create table src_multi2 (i STRING, j STRING NOT NULL ENFORCED) POSTHOOK: type: CREATETABLE POSTHOOK: Output: database:default POSTHOOK: Output: default@src_multi2 -FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: NOT NULL constraint violated! +FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: Either CHECK or NOT NULL constraint violated! diff --git a/ql/src/test/results/clientnegative/insert_overwrite_notnull_constraint.q.out b/ql/src/test/results/clientnegative/insert_overwrite_notnull_constraint.q.out index dd720fad75..96feec0d30 100644 --- a/ql/src/test/results/clientnegative/insert_overwrite_notnull_constraint.q.out +++ b/ql/src/test/results/clientnegative/insert_overwrite_notnull_constraint.q.out @@ -6,4 +6,4 @@ POSTHOOK: query: create table nullConstraintCheck(i int NOT NULL enforced, j int POSTHOOK: type: CREATETABLE POSTHOOK: Output: database:default POSTHOOK: Output: default@nullConstraintCheck -FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: NOT NULL constraint violated! +FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: Either CHECK or NOT NULL constraint violated! diff --git a/ql/src/test/results/clientnegative/update_notnull_constraint.q.out b/ql/src/test/results/clientnegative/update_notnull_constraint.q.out index 8748681dab..86bfc67480 100644 --- a/ql/src/test/results/clientnegative/update_notnull_constraint.q.out +++ b/ql/src/test/results/clientnegative/update_notnull_constraint.q.out @@ -21,4 +21,4 @@ POSTHOOK: Output: default@acid_uami POSTHOOK: Lineage: acid_uami.de SCRIPT [] POSTHOOK: Lineage: acid_uami.i SCRIPT [] POSTHOOK: Lineage: acid_uami.vc SCRIPT [] -FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: NOT NULL constraint violated! +FAILED: DataConstraintViolationError org.apache.hadoop.hive.ql.exec.errors.DataConstraintViolationError: Either CHECK or NOT NULL constraint violated!