[ 
https://issues.apache.org/jira/browse/HIVE-14943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15637968#comment-15637968
 ] 

Alan Gates commented on HIVE-14943:
-----------------------------------

Comments in the code on the review board.  

I also have some questions on how the WHEN clauses work:

The AND segment of the WHEN clause, is the expression evaluated against the 
target table or source table(s) or either or both?

The implementation seems to imply that a single row coming from the source will 
go down a particular branch of the WHEN clause, particularly since it specifies 
that if there are to WHEN MATCHED clauses one must be an UPDATE and one must be 
a DELETE, and since you are requiring and AND in the WHEN.  But AFAICT an AND 
alone isn't sufficient to guarantee a record only applies to one side.  For 
example:
{code}
MERGE INTO T USING U ON T.a = U.a
WHEN MATCHED AND U.timestamp < 'yesterday' THEN DELETE
WHEN MATCHED THEN UPDATE T.timestamp = U.timestamp
WHEN NOT MATCHED THEN INSERT;
{code}
A row with U.timestamp < 'yesterday' matches both the delete and update 
clauses.  How do you decide which wins?  How do you guarantee that the winner 
you want is the winner you get?

On INSERT, are we requiring the VALUES clause or allowing them to omit it (as I 
did above) and assume they mean find matching columns in the source expression 
and target table and insert appropriately?

Finally, all the of the tests are unit tests.  Do you plan to add .q tests 
separately?

> Base Implementation
> -------------------
>
>                 Key: HIVE-14943
>                 URL: https://issues.apache.org/jira/browse/HIVE-14943
>             Project: Hive
>          Issue Type: Sub-task
>          Components: Transactions
>            Reporter: Eugene Koifman
>            Assignee: Eugene Koifman
>         Attachments: HIVE-14943.2.patch, HIVE-14943.3.patch, 
> HIVE-14943.4.patch, HIVE-14943.5.patch, HIVE-14943.6.patch, 
> HIVE-14943.7.patch, HIVE-14943.8.patch, HIVE-14943.9.patch, HIVE-14943.patch
>
>
> Create the 1st pass functional implementation of MERGE
> This should run e2e and produce correct results.  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to