You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cassandra.apache.org by Joe Stein <cr...@gmail.com> on 2013/09/26 03:29:08 UTC

inserting a row with a map column when using if not exists results in null column for the row

Hi, was not sure if there is a reason for this or I am doing something
wrong or is known issue or not but when trying to insert a row with a map
collection column and using if not exist the map is coming out as null :(
see below, let me know, thanks!

cqlsh:rvag> CREATE TABLE users (
        ...     id text PRIMARY KEY,
        ...     given text,
        ...     surname text,
        ...     favs map<text, text>   // A map of text keys, and text
values
        ... );
cqlsh:rvag> INSERT INTO users (id, given, surname, favs)
        ...            VALUES ('jsmith', 'John', 'Smith', { 'fruit' :
'apple', 'band' : 'Beatles' });
cqlsh:rvag> select * from users;

 id     | favs                                  | given | surname
--------+---------------------------------------+-------+---------
 jsmith | {'band': 'Beatles', 'fruit': 'apple'} |  John |   Smith

(1 rows)

cqlsh:rvag> truncate users;
cqlsh:rvag> select * from users;

(0 rows)

cqlsh:rvag> INSERT INTO users (id, given, surname, favs)
        ...            VALUES ('jsmith', 'John', 'Smith', { 'fruit' :
'apple', 'band' : 'Beatles' }) IF NOT EXISTS;
cqlsh:rvag> select * from users;

 id     | favs | given | surname
--------+------+-------+---------
 jsmith | null |  John |   Smith

(1 rows)

/*******************************************
 Joe Stein
 Founder, Principal Consultant
 Big Data Open Source Security LLC
 http://www.stealth.ly
 Twitter: @allthingshadoop <http://www.twitter.com/allthingshadoop>
********************************************/

Re: inserting a row with a map column when using if not exists results in null column for the row

Posted by Joe Stein <cr...@gmail.com>.
yup, thats it :) cool, thanks!

On Wed, Sep 25, 2013 at 9:42 PM, Yuki Morishita <mo...@gmail.com> wrote:

> Sounds like https://issues.apache.org/jira/browse/CASSANDRA-6069
>
> On Wed, Sep 25, 2013 at 8:29 PM, Joe Stein <cr...@gmail.com> wrote:
> > Hi, was not sure if there is a reason for this or I am doing something
> > wrong or is known issue or not but when trying to insert a row with a map
> > collection column and using if not exist the map is coming out as null :(
> > see below, let me know, thanks!
> >
> > cqlsh:rvag> CREATE TABLE users (
> >         ...     id text PRIMARY KEY,
> >         ...     given text,
> >         ...     surname text,
> >         ...     favs map<text, text>   // A map of text keys, and text
> > values
> >         ... );
> > cqlsh:rvag> INSERT INTO users (id, given, surname, favs)
> >         ...            VALUES ('jsmith', 'John', 'Smith', { 'fruit' :
> > 'apple', 'band' : 'Beatles' });
> > cqlsh:rvag> select * from users;
> >
> >  id     | favs                                  | given | surname
> > --------+---------------------------------------+-------+---------
> >  jsmith | {'band': 'Beatles', 'fruit': 'apple'} |  John |   Smith
> >
> > (1 rows)
> >
> > cqlsh:rvag> truncate users;
> > cqlsh:rvag> select * from users;
> >
> > (0 rows)
> >
> > cqlsh:rvag> INSERT INTO users (id, given, surname, favs)
> >         ...            VALUES ('jsmith', 'John', 'Smith', { 'fruit' :
> > 'apple', 'band' : 'Beatles' }) IF NOT EXISTS;
> > cqlsh:rvag> select * from users;
> >
> >  id     | favs | given | surname
> > --------+------+-------+---------
> >  jsmith | null |  John |   Smith
> >
> > (1 rows)
> >
> > /*******************************************
> >  Joe Stein
> >  Founder, Principal Consultant
> >  Big Data Open Source Security LLC
> >  http://www.stealth.ly
> >  Twitter: @allthingshadoop <http://www.twitter.com/allthingshadoop>
> > ********************************************/
>
>
>
> --
> Yuki Morishita
>  t:yukim (http://twitter.com/yukim)
>

Re: inserting a row with a map column when using if not exists results in null column for the row

Posted by Yuki Morishita <mo...@gmail.com>.
Sounds like https://issues.apache.org/jira/browse/CASSANDRA-6069

On Wed, Sep 25, 2013 at 8:29 PM, Joe Stein <cr...@gmail.com> wrote:
> Hi, was not sure if there is a reason for this or I am doing something
> wrong or is known issue or not but when trying to insert a row with a map
> collection column and using if not exist the map is coming out as null :(
> see below, let me know, thanks!
>
> cqlsh:rvag> CREATE TABLE users (
>         ...     id text PRIMARY KEY,
>         ...     given text,
>         ...     surname text,
>         ...     favs map<text, text>   // A map of text keys, and text
> values
>         ... );
> cqlsh:rvag> INSERT INTO users (id, given, surname, favs)
>         ...            VALUES ('jsmith', 'John', 'Smith', { 'fruit' :
> 'apple', 'band' : 'Beatles' });
> cqlsh:rvag> select * from users;
>
>  id     | favs                                  | given | surname
> --------+---------------------------------------+-------+---------
>  jsmith | {'band': 'Beatles', 'fruit': 'apple'} |  John |   Smith
>
> (1 rows)
>
> cqlsh:rvag> truncate users;
> cqlsh:rvag> select * from users;
>
> (0 rows)
>
> cqlsh:rvag> INSERT INTO users (id, given, surname, favs)
>         ...            VALUES ('jsmith', 'John', 'Smith', { 'fruit' :
> 'apple', 'band' : 'Beatles' }) IF NOT EXISTS;
> cqlsh:rvag> select * from users;
>
>  id     | favs | given | surname
> --------+------+-------+---------
>  jsmith | null |  John |   Smith
>
> (1 rows)
>
> /*******************************************
>  Joe Stein
>  Founder, Principal Consultant
>  Big Data Open Source Security LLC
>  http://www.stealth.ly
>  Twitter: @allthingshadoop <http://www.twitter.com/allthingshadoop>
> ********************************************/



-- 
Yuki Morishita
 t:yukim (http://twitter.com/yukim)