[ 
https://issues.apache.org/jira/browse/HIVE-19115?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gopal V updated HIVE-19115:
---------------------------
    Description: 
{code}
create table target stored as orc as select ss_ticket_number, ss_item_sk, 
current_timestamp as `ts` from tpcds_bin_partitioned_orc_1000.store_sales;

create table source stored as orc as select sr_ticket_number, sr_item_sk, 
d_date from tpcds_bin_partitioned_orc_1000.store_returns join 
tpcds_bin_partitioned_orc_1000.date_dim where d_date_sk = sr_returned_date_sk;


merge /* +semi(T, sr_ticket_number, S, 10000) */ into target T using (select * 
from source where year(d_date) = 1998) S ON T.ss_ticket_number = 
S.sr_ticket_number and sr_item_sk = ss_item_sk 
when matched is null THEN UPDATE SET ts = current_timestamp
when not matched and sr_item_sk is not null and sr_ticket_number is not null 
THEN INSERT VALUES(S.sr_ticket_number, S.sr_item_sk, current_timestamp);
{code}

The semijoin hints are ignored and the code says 

{code}
     todo: do we care to preserve comments in original SQL?
{code}


https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java#L624

in this case we do.


  was:
{code}
create table target stored as orc as select ss_ticket_number, ss_item_sk, 
current_timestamp as `ts` from tpcds_bin_partitioned_orc_1000.store_sales;

create table source stored as orc as select sr_ticket_number, sr_item_sk, 
d_date from tpcds_bin_partitioned_orc_1000.store_returns join 
tpcds_bin_partitioned_orc_1000.date_dim where d_date_sk = sr_returned_date_sk;


explain
merge /* +semi(T, sr_ticket_number, S, 10000) */ into target T using (select * 
from source where year(d_date) = 1998) S ON T.ss_ticket_number = 
S.sr_ticket_number and sr_item_sk = ss_item_sk 
when matched and ss_item_sk is null THEN UPDATE SET ts = current_timestamp
when not matched and ss_item_sk is null and sr_item_sk is not null and 
sr_ticket_number is not null THEN INSERT VALUES(S.sr_ticket_number, 
S.sr_item_sk, current_timestamp);
{code}

The semijoin hints are ignored and the code says 

{code}
     todo: do we care to preserve comments in original SQL?
{code}


https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java#L624

in this case we do.



> Merge: Semijoin hints are dropped by the merge
> ----------------------------------------------
>
>                 Key: HIVE-19115
>                 URL: https://issues.apache.org/jira/browse/HIVE-19115
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Gopal V
>            Priority: Major
>
> {code}
> create table target stored as orc as select ss_ticket_number, ss_item_sk, 
> current_timestamp as `ts` from tpcds_bin_partitioned_orc_1000.store_sales;
> create table source stored as orc as select sr_ticket_number, sr_item_sk, 
> d_date from tpcds_bin_partitioned_orc_1000.store_returns join 
> tpcds_bin_partitioned_orc_1000.date_dim where d_date_sk = sr_returned_date_sk;
> merge /* +semi(T, sr_ticket_number, S, 10000) */ into target T using (select 
> * from source where year(d_date) = 1998) S ON T.ss_ticket_number = 
> S.sr_ticket_number and sr_item_sk = ss_item_sk 
> when matched is null THEN UPDATE SET ts = current_timestamp
> when not matched and sr_item_sk is not null and sr_ticket_number is not null 
> THEN INSERT VALUES(S.sr_ticket_number, S.sr_item_sk, current_timestamp);
> {code}
> The semijoin hints are ignored and the code says 
> {code}
>      todo: do we care to preserve comments in original SQL?
> {code}
> https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java#L624
> in this case we do.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to