You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2018/03/25 02:26:18 UTC

[18/19] hive git commit: HIVE-18953 : Implement CHECK constraint (Vineet Garg via Ashutosh Chauhan)

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/java/org/apache/hadoop/hive/ql/plan/CreateTableDesc.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/CreateTableDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/CreateTableDesc.java
index ff9df3d..0429278 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/CreateTableDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/CreateTableDesc.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.Order;
+import org.apache.hadoop.hive.metastore.api.SQLCheckConstraint;
 import org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint;
 import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
 import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
@@ -102,6 +103,7 @@ public class CreateTableDesc extends DDLDesc implements Serializable {
   List<SQLUniqueConstraint> uniqueConstraints;
   List<SQLNotNullConstraint> notNullConstraints;
   List<SQLDefaultConstraint> defaultConstraints;
+  List<SQLCheckConstraint> checkConstraints;
   private Long initialMmWriteId; // Initial MM write ID for CTAS and import.
   // The FSOP configuration for the FSOP that is going to write initial data during ctas.
   // This is not needed beyond compilation, so it is transient.
@@ -122,14 +124,14 @@ public class CreateTableDesc extends DDLDesc implements Serializable {
       boolean ifNotExists, List<String> skewedColNames, List<List<String>> skewedColValues,
       List<SQLPrimaryKey> primaryKeys, List<SQLForeignKey> foreignKeys,
       List<SQLUniqueConstraint> uniqueConstraints, List<SQLNotNullConstraint> notNullConstraints,
-      List<SQLDefaultConstraint> defaultConstraints) {
+      List<SQLDefaultConstraint> defaultConstraints, List<SQLCheckConstraint> checkConstraints) {
 
     this(tableName, isExternal, isTemporary, cols, partCols,
         bucketCols, sortCols, numBuckets, fieldDelim, fieldEscape,
         collItemDelim, mapKeyDelim, lineDelim, comment, inputFormat,
         outputFormat, location, serName, storageHandler, serdeProps,
         tblProps, ifNotExists, skewedColNames, skewedColValues,
-        primaryKeys, foreignKeys, uniqueConstraints, notNullConstraints, defaultConstraints);
+        primaryKeys, foreignKeys, uniqueConstraints, notNullConstraints, defaultConstraints, checkConstraints);
 
     this.databaseName = databaseName;
   }
@@ -146,13 +148,13 @@ public class CreateTableDesc extends DDLDesc implements Serializable {
                          boolean ifNotExists, List<String> skewedColNames, List<List<String>> skewedColValues,
                          boolean isCTAS, List<SQLPrimaryKey> primaryKeys, List<SQLForeignKey> foreignKeys,
                          List<SQLUniqueConstraint> uniqueConstraints, List<SQLNotNullConstraint> notNullConstraints,
-                         List<SQLDefaultConstraint> defaultConstraints) {
+                         List<SQLDefaultConstraint> defaultConstraints, List<SQLCheckConstraint> checkConstraints) {
     this(databaseName, tableName, isExternal, isTemporary, cols, partCols,
             bucketCols, sortCols, numBuckets, fieldDelim, fieldEscape,
             collItemDelim, mapKeyDelim, lineDelim, comment, inputFormat,
             outputFormat, location, serName, storageHandler, serdeProps,
             tblProps, ifNotExists, skewedColNames, skewedColValues,
-            primaryKeys, foreignKeys, uniqueConstraints, notNullConstraints, defaultConstraints);
+            primaryKeys, foreignKeys, uniqueConstraints, notNullConstraints, defaultConstraints, checkConstraints);
     this.isCTAS = isCTAS;
 
   }
@@ -170,7 +172,7 @@ public class CreateTableDesc extends DDLDesc implements Serializable {
       boolean ifNotExists, List<String> skewedColNames, List<List<String>> skewedColValues,
       List<SQLPrimaryKey> primaryKeys, List<SQLForeignKey> foreignKeys,
       List<SQLUniqueConstraint> uniqueConstraints, List<SQLNotNullConstraint> notNullConstraints,
-      List<SQLDefaultConstraint> defaultConstraints) {
+      List<SQLDefaultConstraint> defaultConstraints, List<SQLCheckConstraint> checkConstraints) {
     this.tableName = tableName;
     this.isExternal = isExternal;
     this.isTemporary = isTemporary;
@@ -200,6 +202,7 @@ public class CreateTableDesc extends DDLDesc implements Serializable {
     this.uniqueConstraints = copyList(uniqueConstraints);
     this.notNullConstraints = copyList(notNullConstraints);
     this.defaultConstraints = copyList(defaultConstraints);
+    this.checkConstraints= copyList(checkConstraints);
   }
 
   private static <T> List<T> copyList(List<T> copy) {
@@ -282,6 +285,8 @@ public class CreateTableDesc extends DDLDesc implements Serializable {
     return defaultConstraints;
   }
 
+  public List<SQLCheckConstraint> getCheckConstraints() { return checkConstraints; }
+
   @Explain(displayName = "bucket columns")
   public List<String> getBucketCols() {
     return bucketCols;

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/java/org/apache/hadoop/hive/ql/plan/ImportTableDesc.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ImportTableDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ImportTableDesc.java
index 7a955bc..5fbd33f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ImportTableDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ImportTableDesc.java
@@ -83,6 +83,7 @@ public class ImportTableDesc {
                 null,
                 null,
                 null,
+            null,
             null);
         this.createTblDesc.setStoredAsSubDirectories(table.getSd().isStoredAsSubDirectories());
         break;

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientnegative/check_constraint_aggregate.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/check_constraint_aggregate.q b/ql/src/test/queries/clientnegative/check_constraint_aggregate.q
new file mode 100644
index 0000000..937c692
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/check_constraint_aggregate.q
@@ -0,0 +1,2 @@
+-- aggregates are not allowed
+create table tti(i int check sum(i) > 5);

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientnegative/check_constraint_max_length.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/check_constraint_max_length.q b/ql/src/test/queries/clientnegative/check_constraint_max_length.q
new file mode 100644
index 0000000..9af7451
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/check_constraint_max_length.q
@@ -0,0 +1,4 @@
+-- max allowed length for check value is 255
+-- create with check expression length 256
+create table t (i int, j string CHECK
+	j > '345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234');

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientnegative/check_constraint_nonboolean_expr.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/check_constraint_nonboolean_expr.q b/ql/src/test/queries/clientnegative/check_constraint_nonboolean_expr.q
new file mode 100644
index 0000000..290f97d
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/check_constraint_nonboolean_expr.q
@@ -0,0 +1,2 @@
+-- invalid expression
+create table tti(i int , j int CHECK i+j);

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientnegative/check_constraint_qual_name.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/check_constraint_qual_name.q b/ql/src/test/queries/clientnegative/check_constraint_qual_name.q
new file mode 100644
index 0000000..8b14961
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/check_constraint_qual_name.q
@@ -0,0 +1,2 @@
+-- FULLY Qualified names are not allowed as check expression
+create table tconstr(i int, j int CHECK tconstr.i>j);

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientnegative/check_constraint_subquery.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/check_constraint_subquery.q b/ql/src/test/queries/clientnegative/check_constraint_subquery.q
new file mode 100644
index 0000000..136633c
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/check_constraint_subquery.q
@@ -0,0 +1,2 @@
+-- Subqueries are not allowed as check expression
+create table tconstr(i int check 3=(select count(*) from t));

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientnegative/check_constraint_temporary_udf.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/check_constraint_temporary_udf.q b/ql/src/test/queries/clientnegative/check_constraint_temporary_udf.q
new file mode 100644
index 0000000..d883290
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/check_constraint_temporary_udf.q
@@ -0,0 +1,3 @@
+-- user defined temporary UDFs are not allowed
+CREATE TEMPORARY FUNCTION test_udf2 AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFTestGetJavaString';
+CREATE TABLE tudf(v string CHECK test_udf2(v) <> 'vin');

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientnegative/check_constraint_udtf.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/check_constraint_udtf.q b/ql/src/test/queries/clientnegative/check_constraint_udtf.q
new file mode 100644
index 0000000..0d337ae
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/check_constraint_udtf.q
@@ -0,0 +1,2 @@
+-- UDTFs are not allowed as check expression
+create table tconstr(i int check explode(array(2,3)));

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientnegative/check_constraint_violation.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/check_constraint_violation.q b/ql/src/test/queries/clientnegative/check_constraint_violation.q
new file mode 100644
index 0000000..716b16a
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/check_constraint_violation.q
@@ -0,0 +1,2 @@
+create table tti(i int check i > 5);
+insert into tti values(5);

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientnegative/check_constraint_window_fun.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/check_constraint_window_fun.q b/ql/src/test/queries/clientnegative/check_constraint_window_fun.q
new file mode 100644
index 0000000..da2f763
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/check_constraint_window_fun.q
@@ -0,0 +1,2 @@
+-- Window functions are not allowed as check expression
+create table tconstr(i int check lead(i, 1) > 3);

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientnegative/create_external_with_check_constraint.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/create_external_with_check_constraint.q b/ql/src/test/queries/clientnegative/create_external_with_check_constraint.q
new file mode 100644
index 0000000..f52f02b
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/create_external_with_check_constraint.q
@@ -0,0 +1 @@
+CREATE external TABLE table1 (a INT CHECK a > b DISABLE, b STRING);

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/queries/clientpositive/check_constraint.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/check_constraint.q b/ql/src/test/queries/clientpositive/check_constraint.q
new file mode 100644
index 0000000..c758cd4
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/check_constraint.q
@@ -0,0 +1,192 @@
+ set hive.stats.autogather=false;
+ set hive.support.concurrency=true;
+ set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+CREATE TABLE table1(i int CHECK -i > -10,
+    j int CHECK +j > 10,
+    ij boolean CHECK ij IS NOT NULL,
+    a int CHECK a BETWEEN i AND j,
+    bb float CHECK bb IN (23.4,56,4),
+    d bigint CHECK d > round(567.6) AND d < round(1000.4))
+    clustered by (i) into 2 buckets stored as orc TBLPROPERTIES('transactional'='true');
+DESC FORMATTED table1;
+
+EXPLAIN INSERT INTO table1 values(1,100,true, 5, 23.4, 700.5);
+INSERT INTO table1 values(1,100,true, 5, 23.4, 700.5);
+SELECT * from table1;
+DROP TABLE table1;
+
+-- null check constraint
+CREATE TABLE table2(i int CHECK i + NULL > 0);
+DESC FORMATTED table2;
+EXPLAIN INSERT INTO table2 values(8);
+INSERT INTO table2 values(8);
+select * from table2;
+Drop table table2;
+
+-- UDF created by users
+CREATE FUNCTION test_udf2 AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFTestGetJavaString';
+CREATE TABLE tudf(v string CHECK test_udf2(v) <> 'vin');
+EXPLAIN INSERT INTO tudf values('function1');
+Drop table tudf;
+
+-- multiple constraints
+create table tmulti(url string NOT NULL ENABLE, userName string, numClicks int CHECK numClicks > 0, d date);
+alter table tmulti add constraint un1 UNIQUE (userName, numClicks) DISABLE;
+DESC formatted tmulti;
+EXPLAIN INSERT INTO tmulti values('hive.apache.com', 'user1', 48, '12-01-2018');
+INSERT INTO tmulti values('hive.apache.com', 'user1', 48, '12-01-2018');
+Select * from tmulti;
+Drop table tmulti;
+
+-- case insentivity
+create table tcase(url string NOT NULL ENABLE, userName string, d date, numClicks int CHECK numclicks > 0);
+DESC formatted tcase;
+EXPLAIN INSERT INTO tcase values('hive.apache.com', 'user1', '12-01-2018', 48);
+INSERT INTO tcase values('hive.apache.com', 'user1', '12-01-2018', 48);
+Select * from tcase ;
+Drop table tcase;
+
+-- cast
+create table tcast(url string NOT NULL ENABLE, numClicks int,
+    price FLOAT CHECK cast(numClicks as FLOAT)*price > 10.00);
+DESC FORMATTED tcast;
+EXPLAIN INSERT INTO tcast values('www.google.com', 100, cast(0.5 as float));
+INSERT INTO tcast values('www.google.com', 100, cast(0.5 as float));
+SELECT * from tcast;
+-- check shouldn't fail
+EXPLAIN INSERT INTO tcast(url, price) values('www.yahoo.com', 0.5);
+INSERT INTO tcast(url, price) values('www.yahoo.com', 0.5);
+SELECT * FROM tcast;
+DROP TABLE tcast;
+
+-- complex expression
+create table texpr(i int DEFAULT 89, f float NOT NULL ENABLE, d decimal(4,1),
+    b boolean CHECK ((cast(d as float) + f) < cast(i as float) + (i*i)));
+DESC FORMATTED texpr;
+explain insert into texpr values(3,3.4,5.6,true);
+insert into texpr values(3,3.4,5.6,true);
+SELECT * from texpr;
+DROP TABLE texpr;
+
+-- UPDATE
+create table acid_uami(i int,
+                 de decimal(5,2) constraint nn1 not null enforced,
+                 vc varchar(128) constraint ch2 CHECK de >= cast(i as decimal(5,2)) enforced)
+                 clustered by (i) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true');
+DESC FORMATTED acid_uami;
+
+-- insert as select
+explain insert into table acid_uami select cast(key as int), cast (key as decimal(5,2)), value from src;
+insert into table acid_uami select cast(key as int), cast (key as decimal(5,2)), value from src;
+
+-- insert overwrite
+explain insert overwrite table acid_uami select cast(key as int), cast (key as decimal(5,2)), value
+    from src order by cast(key as int) limit 10 ;
+insert overwrite table acid_uami select cast(key as int), cast (key as decimal(5,2)), value
+    from src order by cast(key as int) limit 10 ;
+
+-- insert as select cont
+explain insert into table acid_uami select cast(s1.key as int) as c1, cast (s2.key as decimal(5,2)) as c2, s1.value from src s1
+    left outer join src s2 on s1.key=s2.key where s1.value > 'val' limit 10 ;
+insert into table acid_uami select cast(s1.key as int) as c1, cast (s2.key as decimal(5,2)) as c2, s1.value from src s1
+    left outer join src s2 on s1.key=s2.key where s1.value > 'val' limit 10 ;
+select * from acid_uami;
+truncate table acid_uami;
+
+-- insert as select group by + agg
+explain insert into table acid_uami select min(cast(key as int)) as c1, max(cast (key as decimal(5,2))) as c2, value
+    from src group by key, value order by key, value limit 10;
+insert into table acid_uami select min(cast(key as int)) as c1, max(cast (key as decimal(5,2))) as c2, value
+    from src group by key, value order by key, value limit 10;
+select * from acid_uami;
+truncate table acid_uami;
+
+-- multi insert
+create table src_multi2 (i STRING, j STRING NOT NULL ENABLE);
+explain
+from src
+insert into table acid_uami select cast(key as int), cast(key as decimal(5,2)), value where key < 10
+insert overwrite table src_multi2 select * where key > 10 and key < 20;
+drop table src_multi2;
+
+-- update
+select * from acid_uami order by de desc limit 15;
+explain update acid_uami set de = 893.14 where de = 103.00 or de = 119.00;
+update acid_uami set de = 893.14 where de = 103.00 or de = 119.00;
+select * from acid_uami order by de desc limit 15;
+ALTER table acid_uami drop constraint ch2;
+explain update acid_uami set vc = 'apache_hive' where de = 893.14 ;
+update acid_uami set vc = 'apache_hive' where de = 893.14 ;
+select * from acid_uami order by vc limit 15;
+DROP TABLE acid_uami;
+
+-- MERGE
+create table tmerge(key int CHECK key > 0 AND (key < 100 OR key = 5) enable, a1 string NOT NULL, value string)
+clustered by (value) into 2 buckets stored as orc
+tblproperties ("transactional"="true");
+DESC FORMATTED tmerge;
+
+create table nonacid (key int, a1 string, value string) stored as orc;
+
+-- with cardinality check off
+set hive.merge.cardinality.check=false;
+explain MERGE INTO tmerge as t using nonacid as s ON t.key = s.key
+WHEN MATCHED AND s.key < 5 THEN DELETE
+WHEN MATCHED AND s.key < 3 THEN UPDATE set a1 = '1'
+WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.a1, s.value);
+
+-- with cardinality check on
+set hive.merge.cardinality.check=true;
+explain MERGE INTO tmerge as t using nonacid as s ON t.key = s.key
+WHEN MATCHED AND s.key < 5 THEN DELETE
+WHEN MATCHED AND s.key < 3 THEN UPDATE set a1 = '1'
+WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.a1, s.value);
+
+explain MERGE INTO tmerge as t using nonacid as s ON t.key = s.key
+WHEN MATCHED AND s.key < 5 THEN DELETE
+WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.a1, s.value);
+
+DROP TABLE tmerge;
+DROP TABLE nonacid;
+
+-- drop constraint
+CREATE TABLE numericDataType(a TINYINT CONSTRAINT tinyint_constraint DEFAULT 127Y ENABLE,
+    b bigint CONSTRAINT check1 CHECK b in(4,5) ENABLE)
+    clustered by (b) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true');
+DESC FORMATTED numericDataType;
+ALTER TABLE numericDataType DROP CONSTRAINT check1;
+DESC FORMATTED numericDataType;
+
+EXPLAIN INSERT INTO numericDataType(b) values(456);
+INSERT INTO numericDataType(b) values(456);
+SELECT * from numericDataType;
+DROP TABLE numericDataType;
+
+-- column reference missing for column having check constraint
+-- NULL for column with check shouldn't be possible
+CREATE TABLE tcheck(a TINYINT, b bigint CONSTRAINT check1 CHECK b in(4,5) ENABLE)
+    clustered by (b) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true');
+DESC FORMATTED tcheck;
+EXPLAIN INSERT INTO tcheck(a) values(1);
+EXPLAIN INSERT INTO tcheck(b) values(4);
+INSERT INTO tcheck(b) values(4);
+SELECT * FROM tcheck;
+DROP TABLE tcheck;
+
+-- micro-managed table
+set hive.create.as.insert.only=true;
+set hive.exec.dynamic.partition.mode=nonstrict;
+create table part_mm(key int check key > 0 and key < 5000 enforced) partitioned by (key_mm int)
+    stored as orc tblproperties ("transactional"="true", "transactional_properties"="insert_only");
+explain insert into table part_mm partition(key_mm=455) select key from src order by value limit 3;
+insert into table part_mm partition(key_mm=455) select key from src order by value desc limit 3;
+select key from src order by value limit 3;
+select * from part_mm;
+drop table part_mm;
+
+-- rely, novalidate
+create table trely(i int);
+ALTER TABLE trely CHANGE i i int CHECK i>0 ENABLE NOVALIDATE RELY;
+DESC FORMATTED trely;
+DROP TABLE trely;

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/results/clientnegative/check_constraint_aggregate.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/check_constraint_aggregate.q.out b/ql/src/test/results/clientnegative/check_constraint_aggregate.q.out
new file mode 100644
index 0000000..e641c81
--- /dev/null
+++ b/ql/src/test/results/clientnegative/check_constraint_aggregate.q.out
@@ -0,0 +1 @@
+FAILED: SemanticException [Error 10128]: Invalid Constraint syntax Invalid CHECK constraint expression: sum(i) > 5. Line 1:0 Not yet supported place for UDAF 'sum'

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/results/clientnegative/check_constraint_max_length.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/check_constraint_max_length.q.out b/ql/src/test/results/clientnegative/check_constraint_max_length.q.out
new file mode 100644
index 0000000..a3eb23f
--- /dev/null
+++ b/ql/src/test/results/clientnegative/check_constraint_max_length.q.out
@@ -0,0 +1 @@
+FAILED: SemanticException [Error 10326]: Invalid Constraint syntax Constraint value: j > '345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234' exceeded maximum allowed length: 255

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/results/clientnegative/check_constraint_nonboolean_expr.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/check_constraint_nonboolean_expr.q.out b/ql/src/test/results/clientnegative/check_constraint_nonboolean_expr.q.out
new file mode 100644
index 0000000..fe64d2c
--- /dev/null
+++ b/ql/src/test/results/clientnegative/check_constraint_nonboolean_expr.q.out
@@ -0,0 +1 @@
+FAILED: SemanticException [Error 10326]: Invalid Constraint syntax Invalid CHECK constraint expression: i+j. Invalid Constraint syntax Only boolean type is supported for CHECK constraint: i+j. Found: int

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/results/clientnegative/check_constraint_qual_name.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/check_constraint_qual_name.q.out b/ql/src/test/results/clientnegative/check_constraint_qual_name.q.out
new file mode 100644
index 0000000..bbda7f5
--- /dev/null
+++ b/ql/src/test/results/clientnegative/check_constraint_qual_name.q.out
@@ -0,0 +1 @@
+FAILED: SemanticException [Error 10326]: Invalid Constraint syntax Invalid CHECK constraint expression: tconstr.i>j. Invalid Constraint syntax Invalid type for CHECK constraint: tconstr.i>j

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/results/clientnegative/check_constraint_subquery.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/check_constraint_subquery.q.out b/ql/src/test/results/clientnegative/check_constraint_subquery.q.out
new file mode 100644
index 0000000..c34251e
--- /dev/null
+++ b/ql/src/test/results/clientnegative/check_constraint_subquery.q.out
@@ -0,0 +1 @@
+FAILED: SemanticException [Error 10326]: Invalid Constraint syntax Invalid CHECK constraint expression: 3=(select count(*) from t). Invalid Constraint syntax Subqueries are not allowed in Check Constraints

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/results/clientnegative/check_constraint_temporary_udf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/check_constraint_temporary_udf.q.out b/ql/src/test/results/clientnegative/check_constraint_temporary_udf.q.out
new file mode 100644
index 0000000..4eb4526
--- /dev/null
+++ b/ql/src/test/results/clientnegative/check_constraint_temporary_udf.q.out
@@ -0,0 +1,7 @@
+PREHOOK: query: CREATE TEMPORARY FUNCTION test_udf2 AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFTestGetJavaString'
+PREHOOK: type: CREATEFUNCTION
+PREHOOK: Output: test_udf2
+POSTHOOK: query: CREATE TEMPORARY FUNCTION test_udf2 AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFTestGetJavaString'
+POSTHOOK: type: CREATEFUNCTION
+POSTHOOK: Output: test_udf2
+FAILED: SemanticException [Error 10326]: Invalid Constraint syntax Invalid CHECK constraint expression: test_udf2(v) <> 'vin'. Invalid Constraint syntax Temporary UDFs are not allowed in Check Constraints

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/results/clientnegative/check_constraint_udtf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/check_constraint_udtf.q.out b/ql/src/test/results/clientnegative/check_constraint_udtf.q.out
new file mode 100644
index 0000000..d2fa20a
--- /dev/null
+++ b/ql/src/test/results/clientnegative/check_constraint_udtf.q.out
@@ -0,0 +1 @@
+FAILED: SemanticException [Error 10326]: Invalid Constraint syntax Invalid CHECK constraint expression: explode(array(2,3)). UDTF's are not supported outside the SELECT clause, nor nested in expressions

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/results/clientnegative/check_constraint_violation.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/check_constraint_violation.q.out b/ql/src/test/results/clientnegative/check_constraint_violation.q.out
new file mode 100644
index 0000000..82f367c
--- /dev/null
+++ b/ql/src/test/results/clientnegative/check_constraint_violation.q.out
@@ -0,0 +1,14 @@
+PREHOOK: query: create table tti(i int check i > 5)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tti
+POSTHOOK: query: create table tti(i int check i > 5)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tti
+PREHOOK: query: insert into tti values(5)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tti
+#### A masked pattern was here ####
+FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/results/clientnegative/check_constraint_window_fun.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/check_constraint_window_fun.q.out b/ql/src/test/results/clientnegative/check_constraint_window_fun.q.out
new file mode 100644
index 0000000..8582ea9
--- /dev/null
+++ b/ql/src/test/results/clientnegative/check_constraint_window_fun.q.out
@@ -0,0 +1 @@
+FAILED: SemanticException [Error 10326]: Invalid Constraint syntax Invalid CHECK constraint expression: lead(i, 1) > 3. Invalid Constraint syntax Window functions are not allowed in Check Constraints

http://git-wip-us.apache.org/repos/asf/hive/blob/5b222db3/ql/src/test/results/clientnegative/create_external_with_check_constraint.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/create_external_with_check_constraint.q.out b/ql/src/test/results/clientnegative/create_external_with_check_constraint.q.out
new file mode 100644
index 0000000..e69566d
--- /dev/null
+++ b/ql/src/test/results/clientnegative/create_external_with_check_constraint.q.out
@@ -0,0 +1 @@
+FAILED: SemanticException [Error 10326]: Invalid Constraint syntax Constraints are disallowed with External tables. Only RELY is allowed.