You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kudu.apache.org by "Yingchun Lai (Jira)" <ji...@apache.org> on 2022/02/21 03:19:00 UTC

[jira] [Comment Edited] (KUDU-3353) Support setnx semantic on column

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

Yingchun Lai edited comment on KUDU-3353 at 2/21/22, 3:18 AM:
--------------------------------------------------------------

I should clarify that no matter what the schema is, include SETNX columns or not, the update ops will update the row anyway, the difference is whether to update the cells or not.

Suppose a table with schema:
{code:java}
TABLE test (
    key INT64 NOT NULL,
    value1 INT64 NULLABLE,
    value2 INT64 NULLABLE UPDATE_IF_NULL,   // this is a SETNX column
    PRIMARY KEY (key)
) ...{code}
case 1: upsert ops on the table are:
{code:java}
upsert1: 1, 2, 3
upsert2: 1, 20, 30{code}
Then the result will be '1, 20, 3'. (30 will not overwite 3 because it's not NULL)

case 2: upsert ops on the table are:
{code:java}
upsert1: 1, 2, null
upsert2: 1, 20, 30{code}
Then the result will be '1, 20, 30'. (30 will be update because it's NULL)

All the cells in upsert/update ops will be kept as before in changelist, the difference is the behavior of delta applier, overwrite the cell or ignore.


was (Author: laiyingchun):
I should clarify that no matter what the schema is, include SETNX columns or not, the update ops will update the row anyway, the difference is whether to update the cells or not.

Suppose a table with schema:

 
{code:java}
TABLE test (
    key INT64 NOT NULL,
    value1 INT64 NULLABLE,
    value2 INT64 NULLABLE UPDATE_IF_NULL,   // this is a SETNX column
    PRIMARY KEY (key)
) ...{code}
case 1: upsert ops on the table are:

 

 
{code:java}
upsert1: 1, 2, 3
upsert2: 1, 20, 30{code}
Then the result will be '1, 20, 3'. (30 will not overwite 3 because it's not NULL)

case 2: upsert ops on the table are:
{code:java}
upsert1: 1, 2, null
upsert2: 1, 20, 30{code}
Then the result will be '1, 20, 30'. (30 will be update because it's NULL)

All the cells in upsert/update ops will be kept as before in changelist, the difference is the behavior of delta applier, overwrite the cell or ignore.

 

> Support setnx semantic on column
> --------------------------------
>
>                 Key: KUDU-3353
>                 URL: https://issues.apache.org/jira/browse/KUDU-3353
>             Project: Kudu
>          Issue Type: New Feature
>          Components: api, server
>            Reporter: Yingchun Lai
>            Priority: Major
>
> h1. motivation
> In some usage scenarios, Kudu table has a column with semantic of "create time", which means it represent the create timestamp of the row. The other columns have the similar semantic as before, for example, the user properties like age, address, and etc.
> Upstream and Kudu user doesn't know whether a row is exist or not, and every cell data is the lastest ingested from, for example, event stream.
> If without the "create time" column, Kudu user can use UPSERT operations to write data to the table, every columns with data will overwrite the old data. But if with the "create time" column, the cell data will be overwrote by the following UPSERT ops, which is not what we expect.
> To achive the goal, we have to read the column out to judge whether the column is NULL or not, if it's NULL, we can fill the row with the cell, if not NULL, we will drop it from the data before UPSERT, to avoid overwite "create time".
> It's expensive, is there a way to avoid a read from Kudu?
> h1. Resolvation
> We can implement column schema with semantic of "update if null". That means cell data in changelist will update the base data if the latter is NULL, and will ignore updates if it is not NULL.
> So we can use Kudu similarly as before, but only defined the column as "update if null" when create table or add column.
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)