You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Hussain Towaileb (JIRA)" <ji...@apache.org> on 2019/05/08 07:37:00 UTC

[jira] [Commented] (ASTERIXDB-2535) UPSERT and UUIDs are broken if used together

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

Hussain Towaileb commented on ASTERIXDB-2535:
---------------------------------------------

There is a fix that's on-ongoing for this issue, please find below the newly intended behavior:

*Case 1: INSERT statement*
 * *UUID present in the statement:* the UUID that's provided by the user in the statement will be used and no new UUID will be generated. If the provided UUID does not exist already, this operation is going to be a normal INSERT operation, but if the provided UUID already exists, this operation is going to return an "inserting duplicate keys into the primary storage" error.
 * *UUID not present in the statement:* a new UUID will be generated and merged with the record, then the record will be inserted.

 

*Case 2: UPSERT statement*
 * *UUID present in the statement:* the UUID that's provided by the user in the statement will be used and no new UUID will be generated. If the provided UUID does not exist already, this operation is going to be a normal INSERT operation, but if the provided UUID already exists, this is going to be an UPDATE operation for the record containing the provided UUID.
 * *UUID not present in the statement:* a new UUID will be generated and merged with the record, then the record will be inserted.

> UPSERT and UUIDs are broken if used together
> --------------------------------------------
>
>                 Key: ASTERIXDB-2535
>                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-2535
>             Project: Apache AsterixDB
>          Issue Type: Bug
>          Components: COMP - Compiler, SQL - Translator SQL++
>    Affects Versions: 0.9.4
>            Reporter: Michael J. Carey
>            Assignee: Hussain Towaileb
>            Priority: Major
>             Fix For: 0.9.5
>
>
> UPSERT doesn't work right for datasets with auto-generated (UUID) keys.  Both UPSERT and INSERT blindly generate and add the key - and if the incoming record already has a key value, they fail with an object-merge error (note that we need to improve the msg too!) due to what then becomes a duplicate field.  What's needed is to get them both to do to the right thing - which would be to use the incoming key value if there is one and only generate one only if there isn't one in the incoming object. This is especially a problem for UPSERTs, as it means we currently cannot ever update data in datasets with system-generated keys (!!!).  (For INSERT we could just make a rule that you can't pass in a key if you're going into auto-keyed dataset.)  This is a major bummer for open-source users who want to use UUIDs.



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