[Question posted by a user on YugabyteDB Community Slack ]
If I use IF NOT EXISTS
clause then YB
is not returning all columns, if the row already exists. This is not the case with cassandra
.
# YCQL
$ create table test.sample (ip inet, hr int, source text, source_id text, g map<int, int>, b map<int, int>, r map<int, int>, c map<int, blob>, primary key(ip, hr, source, source_id));
$ insert into sample(ip, hr, source, source_id, g, b, r,c) values('1.2.3.4', 456, 'alpha', 'a', {0:1}, {1:2},{2:1},{0: 0x12});
$ insert into sample(ip, hr, source, source_id, g, b, r,c) values('1.2.3.4', 456, 'alpha', 'a', {0:1}, {1:2},{2:1},{0: 0x12}) if not exists;
[applied] | ip | hr | source | source_id
-----------+---------+-----+--------+-----------
False | 1.2.3.4 | 456 | alpha | a
# cassandra
$ create table test.sample (ip inet, hr int, source text, source_id text, g map<int, int>, b map<int, int>, r map<int, int>, c map<int, blob>, primary key(ip, hr, source, source_id));
$ insert into sample(ip, hr, source, source_id, g, b, r,c) values('1.2.3.4', 456, 'alpha', 'a', {0:1}, {1:2},{2:1},{0: 0x12}) ;
$ insert into sample(ip, hr, source, source_id, g, b, r,c) values('1.2.3.4', 456, 'alpha', 'a', {0:1}, {1:2},{2:1},{0: 0x12}) if not exists;
[applied] | ip | hr | source | source_id | b | c | g | r
-----------+---------+-----+--------+-----------+--------+-----------+--------+--------
False | 1.2.3.4 | 456 | alpha | a | {1: 2} | {0: 0x12} | {0: 1} | {2: 1}
It would have helpful to return all columns for IF NOT EXISTS
clause, otherwise I need to read row again.