Re: IF NOT EXISTS on UPDATE statements?

2014-12-30 Thread DuyHai Doan
@cassandra.apache.org Date: Tuesday, November 18, 2014 at 2:26 PM To: user@cassandra.apache.org Subject: Re: IF NOT EXISTS on UPDATE statements? For (2), we would love to see: UPSERT value=new_value where (not exists || value=read_value) That would be something like UPDATE … IF column=value

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Sylvain Lebresne
On Mon, Nov 17, 2014 at 10:52 PM, Kevin Burton bur...@spinn3r.com wrote: There’s still a lot of weirdness in CQL. For example, you can do an INSERT with an UPDATE .. .which I’m generally fine with. Kind of make sense. However, with INSERT you can do IF NOT EXISTS. … but you can’t do the

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Kevin Burton
There is no way to mimic IF NOT EXISTS on UPDATE and it's not a bug. INSERT and UPDATE are not totally orthogonal in CQL and you should use INSERT for actual insertion and UPDATE for updates (granted, the database will not reject our query if you break this rule but it's nonetheless the way it's

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Robert Stupp
There is no way to mimic IF NOT EXISTS on UPDATE and it's not a bug. INSERT and UPDATE are not totally orthogonal in CQL and you should use INSERT for actual insertion and UPDATE for updates (granted, the database will not reject our query if you break this rule but it's nonetheless the

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Brian O'Neill
other than the intended recipient is strictly prohibited. From: Robert Stupp sn...@snazy.de Reply-To: user@cassandra.apache.org Date: Tuesday, November 18, 2014 at 12:35 PM To: user@cassandra.apache.org Subject: Re: IF NOT EXISTS on UPDATE statements? There is no way to mimic

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Robert Stupp
For (2), we would love to see: UPSERT value=new_value where (not exists || value=read_value) That would be something like UPDATE … IF column=value OR NOT EXISTS“. Took at the C* source and that feels like a LHF (for 3.0) so I opened https://issues.apache.org/jira/browse/CASSANDRA-8335 for

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Brian O'Neill
. From: Robert Stupp sn...@snazy.de Reply-To: user@cassandra.apache.org Date: Tuesday, November 18, 2014 at 2:26 PM To: user@cassandra.apache.org Subject: Re: IF NOT EXISTS on UPDATE statements? For (2), we would love to see: UPSERT value=new_value where (not exists || value=read_value

IF NOT EXISTS on UPDATE statements?

2014-11-17 Thread Kevin Burton
There’s still a lot of weirdness in CQL. For example, you can do an INSERT with an UPDATE .. .which I’m generally fine with. Kind of make sense. However, with INSERT you can do IF NOT EXISTS. … but you can’t do the same thing on UPDATE. So I foolishly wrote all my code assuming that

Re: IF NOT EXISTS on UPDATE statements?

2014-11-17 Thread DuyHai Doan
So I foolishly wrote all my code assuming that INSERT/UPDATE were orthogonal, but now they’re not There are some subtle differences. INSERT will create marker columns, UPDATE won't touch/modify them. What are marker columns ? Some insights here:

Re: IF NOT EXISTS on UPDATE statements?

2014-11-17 Thread Kevin Burton
you can still do IF on UPDATE though… but it’s not possible to do IF mycolumn IS NULL -- If mycolumn = null should work Alas.. it doesn’t :-/ -- Founder/CEO Spinn3r.com Location: *San Francisco, CA* blog: http://burtonator.wordpress.com … or check out my Google+ profile

Re: IF NOT EXISTS on UPDATE statements?

2014-11-17 Thread DuyHai Doan
Just tested with C* 2.1.1 cqlsh:test CREATE TABLE simple(id int PRIMARY KEY, val text); cqlsh:test INSERT INTO simple (id) VALUES (1); cqlsh:test SELECT * FROM simple ; id | val +-- 1 | null (1 rows) cqlsh:test UPDATE simple SET val = 'new val' WHERE id=1 *IF val = null*;

Re: IF NOT EXISTS on UPDATE statements?

2014-11-17 Thread Kevin Burton
Oh yes. That will work because a value is already there. I’m talking if the value does not exist. Otherwise I’d have to insert a null first. On Mon, Nov 17, 2014 at 3:30 PM, DuyHai Doan doanduy...@gmail.com wrote: Just tested with C* 2.1.1 cqlsh:test CREATE TABLE simple(id int PRIMARY KEY,