Krisztian Kasa created HIVE-23089:
-------------------------------------
Summary: Add constraint checks to CBO plan
Key: HIVE-23089
URL: https://issues.apache.org/jira/browse/HIVE-23089
Project: Hive
Issue Type: Improvement
Components: CBO
Reporter: Krisztian Kasa
Assignee: Krisztian Kasa
{code}
create table acid_uami(i int,
de decimal(5,2) constraint nn1 not null enforced,
vc varchar(128) constraint nn2 not null enforced) clustered by
(i) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true');
explain
update acid_uami set de=null where i=1;
{code}
Non-CBO path:
{code:java}
Map Operator Tree:
TableScan
alias: acid_uami
filterExpr: ((i = 1) and enforce_constraint(vc is not null)) (type:
boolean)
Statistics: Num rows: 1 Data size: 216 Basic stats: COMPLETE Column
stats: NONE
Filter Operator
predicate: ((i = 1) and enforce_constraint(vc is not null))
(type: boolean)
{code}
CBO path:
{code:java}
Map Reduce
Map Operator Tree:
TableScan
alias: acid_uami
filterExpr: (i = 1) (type: boolean)
Statistics: Num rows: 1 Data size: 216 Basic stats: COMPLETE Column
stats: NONE
Filter Operator
predicate: (i = 1) (type: boolean)
...
Reduce Operator Tree:
...
Filter Operator
predicate: enforce_constraint((null is not null and _col3 is not
null)) (type: boolean)
{code}
In CBO path the enforce_constraint function is added to the plan when CBO plan
is already generated and optimized.
{code}
HiveSortExchange(distribution=[any], collation=[[0]])
HiveProject(row__id=[$5], i=[CAST(1):INTEGER], _o__c2=[null:NULL], vc=[$2])
HiveFilter(condition=[=($0, 1)])
HiveTableScan(table=[[default, acid_uami]], table:alias=[acid_uami])
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)