You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Selvam Raman <se...@gmail.com> on 2016/11/29 13:47:54 UTC

Java Collections.emptyList inserted as null object in cassandra

Filed Type in cassandra : List<Text>

I am trying to insert  Collections.emptyList() from spark to cassandra
list<Text> field. In cassandra it stores as null object.

How can i avoid null values here.

-- 
Selvam Raman
"லஞ்சம் தவிர்த்து நெஞ்சம் நிமிர்த்து"

Re: Java Collections.emptyList inserted as null object in cassandra

Posted by Cody Yancey <ya...@uber.com>.
It is not possible. Internally Cassandra flattens your data out into a set
of key-value-pairs. All collection types, including lists, are nothing more
than a thin layer of schema over a clustered set of key-value-pairs, so on
disk there is no difference between an empty list and a list that doesn't
exist. If you need to differentiate between the two, you will need a
separate "isSet" column that is a 1 or a 0 to indicate the presence or
absence of a list and write your client-side code to branch on that new
column instead.

Thanks,
Cody

On Tue, Nov 29, 2016 at 6:47 AM, Selvam Raman <se...@gmail.com> wrote:

> Filed Type in cassandra : List<Text>
>
> I am trying to insert  Collections.emptyList() from spark to cassandra
> list<Text> field. In cassandra it stores as null object.
>
> How can i avoid null values here.
>
> --
> Selvam Raman
> "லஞ்சம் தவிர்த்து நெஞ்சம் நிமிர்த்து"
>

Re: Java Collections.emptyList inserted as null object in cassandra

Posted by Cody Yancey <ya...@uber.com>.
It is not possible. Internally Cassandra flattens your data out into a set
of key-value-pairs. All collection types, including lists, are nothing more
than a thin layer of schema over a clustered set of key-value-pairs, so on
disk there is no difference between an empty list and a list that doesn't
exist. If you need to differentiate between the two, you will need a
separate "isSet" column that is a 1 or a 0 to indicate the presence or
absence of a list and write your client-side code to branch on that new
column instead.

Thanks,
Cody

On Tue, Nov 29, 2016 at 6:47 AM, Selvam Raman <se...@gmail.com> wrote:

> Filed Type in cassandra : List<Text>
>
> I am trying to insert  Collections.emptyList() from spark to cassandra
> list<Text> field. In cassandra it stores as null object.
>
> How can i avoid null values here.
>
> --
> Selvam Raman
> "லஞ்சம் தவிர்த்து நெஞ்சம் நிமிர்த்து"
>