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

Zoltan Haindrich commented on HIVE-25404:
-----------------------------------------

we could fix the rewrite to  be correct
{code}
#1) INSERT INTO `default`.`t` partition (`id`) (`value`)    -- insert clause
#2) INSERT INTO `default`.`t` partition (`id`) ()    -- insert clause
{code}
however in #2 case we will bump into that we don't support empty column lists

or we could probably rely on HIVE-? and proceed without the partition keyword
{code}
#1) INSERT INTO `default`.`t` (`id`,`value`)    -- insert clause
#2) INSERT INTO `default`.`t` (`id`)    -- insert clause
{code}

> Inserts inside merge statements are rewritten incorrectly for partitioned 
> tables
> --------------------------------------------------------------------------------
>
>                 Key: HIVE-25404
>                 URL: https://issues.apache.org/jira/browse/HIVE-25404
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Zoltan Haindrich
>            Priority: Major
>
> {code}
> drop table u;drop table t;
> create table t(value string default 'def') partitioned by (id integer);
> create table u(id integer);
> {code}
> #1 id&value specified
> rewritten
> {code}
> FROM
>   `default`.`t`
>   RIGHT OUTER JOIN
>   `default`.`u`
>   ON `t`.`id`=`u`.`id`
> INSERT INTO `default`.`t` (`id`,`value`) partition (`id`)    -- insert clause
>   SELECT `u`.`id`,'x'
>    WHERE `t`.`id` IS NULL
> {code}
> #2 when values is not specified
> {code}
> merge into t using u on t.id=u.id when not matched then insert (id) values 
> (u.id);
> {code}
> rewritten query:
> {code}
> FROM
>   `default`.`t`
>   RIGHT OUTER JOIN
>   `default`.`u`
>   ON `t`.`id`=`u`.`id`
> INSERT INTO `default`.`t` (`id`) partition (`id`)    -- insert clause
>   SELECT `u`.`id`
>    WHERE `t`.`id` IS NULL
> {code}



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

Reply via email to