You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2014/12/03 22:29:13 UTC

[jira] [Commented] (CALCITE-492) Support UPSERT statement in parser

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

Julian Hyde commented on CALCITE-492:
-------------------------------------

I was initially thinking we would have create a Phoenix-specific extension to the parser. But since UPSERT is identical to INSERT except for the first word, that would seem to be overkill. I think it would work to add a new reserved word, parse UPSERT as INSERT, and add a boolean flag to SqlInsert AST node.

That flag would be carried into the TableModify relational expression, perhaps an extra value in its enum Operation { INSERT, UPDATE, DELETE, MERGE }. It's TBD whether UPSERT behaves more like INSERT or MERGE during optimization. It's clear that it's more like INSERT at parse time.

> Support UPSERT statement in parser
> ----------------------------------
>
>                 Key: CALCITE-492
>                 URL: https://issues.apache.org/jira/browse/CALCITE-492
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: James Taylor
>            Assignee: Julian Hyde
>              Labels: phoenix
>
> Support an UPSERT VALUES and UPSERT SELECT statement in Calcite. These have the same syntax as INSERT VALUES and INSERT SELECT, but they insert the row if it doesn't already exist and update it otherwise. This is a pretty common pattern for big data applications that want to have an option to write without reading first. See http://phoenix.apache.org/language/index.html#upsert_values and http://phoenix.apache.org/language/index.html#upsert_select for syntax.



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