Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YCQL] Identify if an upsert operation inserts or updates fails #13606

Open
beatrausch opened this issue Aug 12, 2022 · 7 comments
Open

[YCQL] Identify if an upsert operation inserts or updates fails #13606

beatrausch opened this issue Aug 12, 2022 · 7 comments
Labels
area/ycql Yugabyte CQL (YCQL) kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue

Comments

@beatrausch
Copy link

beatrausch commented Aug 12, 2022

Jira Link: DB-3181

Description

Hi,

we try to identify if an upsert statement inserts or updates the row based on the RETURNS STATUS AS ROW.
When we run the following example with YB Version 2.14.1.0 it does not seem to work as expected:

ycqlsh> create keyspace ks;
ycqlsh> use ks;
ycqlsh:ks> create table test(key text primary key, value text, checkpoint text);
# Inserting a new row
ycqlsh:ks> update test set value='v1', checkpoint='c1' where key='k1' if checkpoint='' or not exists returns status as row;

[applied] | [message] | key  | value | checkpoint
-----------+-----------+------+-------+------------
      True |      null | null |  null |       null

For the insert we would expect applied=false

# Updating an existing row
ycqlsh:ks> update test set value='v1', checkpoint='c1' where key='k1' if checkpoint='c1' or not exists returns status as row;

[applied] | [message] | key  | value | checkpoint
-----------+-----------+------+-------+------------
      True |      null | null |  null |       null

Works as expected

@beatrausch beatrausch added area/ycql Yugabyte CQL (YCQL) status/awaiting-triage Issue awaiting triage labels Aug 12, 2022
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Aug 12, 2022
@ddorian
Copy link
Contributor

ddorian commented Aug 13, 2022

For the insert we would expect applied=false

But the row is inserted (because of or not exists).

Updates in YCQL are like UPSERTS. Example

ycqlsh:ks> update test set value='v1', checkpoint='c1' where key='k2' returns status as row;

 [applied] | [message] | key  | value | checkpoint
-----------+-----------+------+-------+------------
      True |      null | null |  null |       null

ycqlsh:ks> select * from test;

 key | value | checkpoint
-----+-------+------------
  k2 |    v1 |         c1

(1 rows)

@beatrausch
Copy link
Author

@ddorian If this behavior is intended, what is the best way to distinguish/identify if a value is inserted or updated when using an upsert statement?

@yugabyte-ci yugabyte-ci removed the status/awaiting-triage Issue awaiting triage label Aug 17, 2022
@ddorian
Copy link
Contributor

ddorian commented Aug 19, 2022

what is the best way to distinguish/identify if a value is inserted or updated when using an upsert statement?

It's not currently possible to distinguish because it doesn't do a read to check if the row exists or not.

@beatrausch
Copy link
Author

@ddorian What do you think, does it make sense to support such kind of feature?

@ddorian
Copy link
Contributor

ddorian commented Aug 31, 2022

@ddorian What do you think, does it make sense to support such kind of feature?

@beatrausch personally, no.

This feature is already supported in YSQL, so you can use that API if you need it.

YCQL is supposed to compete with Cassandra (where this feature has very low chance of landing)

@in-cloud-opensource
Copy link

@ddorian If you want to use the TTL feature from YCQL that is not possible with YSQL right?

@ddorian
Copy link
Contributor

ddorian commented Sep 1, 2022

If you want to use the TTL feature from YCQL that is not possible with YSQL right?

@in-cloud-opensource no, it's not.

Can you explain your complete use case for this table where you need TTL & UPSERT ?
You can do it on the forums,slack, or here.

@yugabyte-ci yugabyte-ci added kind/enhancement This is an enhancement of an existing feature and removed kind/bug This issue is a bug labels Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ycql Yugabyte CQL (YCQL) kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue
Projects
None yet
Development

No branches or pull requests

4 participants