You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Krisztian Kasa (Jira)" <ji...@apache.org> on 2021/09/10 09:10:00 UTC

[jira] [Created] (HIVE-25512) Merge statement does not enforce check constraints

Krisztian Kasa created HIVE-25512:
-------------------------------------

             Summary: Merge statement does not enforce check constraints
                 Key: HIVE-25512
                 URL: https://issues.apache.org/jira/browse/HIVE-25512
             Project: Hive
          Issue Type: Bug
            Reporter: Krisztian Kasa
            Assignee: Krisztian Kasa


{code}
set hive.support.concurrency=true;
set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;

CREATE TABLE table_check_merge(
name string CHECK (length(name)<=20),
age int,
gpa double CHECK (gpa BETWEEN 0.0 AND 4.0)
) stored as orc TBLPROPERTIES ('transactional'='true');

CREATE TABLE table_source( name string, age int, gpa double);

insert into table_source(name, age, gpa) values ('student1', 16, null), (null, 20, 4.0);

insert into table_check_merge(name, age, gpa) values ('student1', 16, 2.0);

merge into table_check_merge using (select age from table_source)source
on source.age=table_check_merge.age
when matched then update set gpa=6;
{code}

Merge statement tries to update gpa to 6 which is not between 0.0 and 4.0.
However the update succeeds.




--
This message was sent by Atlassian Jira
(v8.3.4#803005)