You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Leonid Ilyevsky <li...@mooncapital.com> on 2012/06/07 23:34:56 UTC

Setting column to null

Is it possible to explicitly set a column value to null?

I see that if insert statement does not include a specific column, that column comes up as null (assuming we are creating a record with new unique key).
But if we want to update a record, how we set it to null?

Another situation is when I use prepared cql3 statement (in Java) and send parameters when I execute it. If I want to leave some column unassigned, I need a special statement without that column.
What I would like is, prepare one statement including all columns, and then be able to set some of them to null. I tried to set corresponding ByteBuffer parameter to null, obviously got an exception.

________________________________
This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP ("Moon Capital"). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

Re: Setting column to null

Posted by Derek Williams <de...@fyrie.net>.
On Tue, Jun 12, 2012 at 9:59 AM, Leonid Ilyevsky <li...@mooncapital.com>
 wrote:

> Thanks Roshni,
>
> I actually looked at Hector, didn't like it that much. Too many methods,
> feels like there are ten ways to do the same thing, but very difficult to
> find the one you need. Many packages look like they are simply migrated
> from Cassandra and renamed, what is the point? In my opinion, it is not
> well architectured API.
> Anyway, I prefer simplicity of CQL, I want to just prepare and execute
> statements. By the way, the manual for CQL is decent compare to the jungle
> of Hector (and Cassandra API too).


There are some related tickets for null support, of course that doesn't
mean it will actually get in:

https://issues.apache.org/jira/browse/CASSANDRA-4147
https://issues.apache.org/jira/browse/CASSANDRA-3783

It would make prepared statements more flexible if there was some amount of
null support.

My only other wishlist item is the ability to set the timestamp, ttl, and
consistency level using prepared statements.

-- 
Derek Williams

RE: Setting column to null

Posted by Leonid Ilyevsky <li...@mooncapital.com>.
Thanks Roshni,

I actually looked at Hector, didn't like it that much. Too many methods, feels like there are ten ways to do the same thing, but very difficult to find the one you need. Many packages look like they are simply migrated from Cassandra and renamed, what is the point? In my opinion, it is not well architectured API.
Anyway, I prefer simplicity of CQL, I want to just prepare and execute statements. By the way, the manual for CQL is decent compare to the jungle of Hector (and Cassandra API too).

-----Original Message-----
From: Roshni Rajagopal [mailto:Roshni.Rajagopal@wal-mart.com]
Sent: Tuesday, June 12, 2012 1:20 AM
To: user@cassandra.apache.org
Subject: Re: Setting column to null

Leonid,


Are you using some client for doing these operations..?

Hector is a java client which provides APIs for adding/deleting columns to
a column family in cassandra.
I don¹t think you really need to write your wrapper in this format- you
are restricting the number of columns it can use etc.I suggest your code
can  accept user input to get col family name, operation, keys  , and
operation, and accordingly call the appropriate hector API for
adding/deleting data.


Regards,
Roshni


On 11/06/12 7:20 PM, "Leonid Ilyevsky" <li...@mooncapital.com> wrote:

>Thanks, I understand what you are telling me. Obviously deleting the
>column is the proper way to do this in Cassandra.
>What I was looking for, is some convenient wrapper on top of that which
>will do it for me. Here is my scenario.
>
>I have a function that takes a record to be saved in Cassandra (array of
>objects, or Map<String, Object>). Let say, it can have up to 8 columns. I
>prepare a statement like this:
>
>Insert into <table> values(?, ?, ?, ?, ?, ?, ?, ?)
>
>If I somehow could put null when I execute it, it would be enough to
>prepare that statement once and execute it multiple times. I would then
>expect that when some element is null, the corresponding column is not
>inserted (for the new key) or deleted (for the existing key).
>The way it is now, in my code I have to examine which columns are present
>and which are not, depending on that I have to generate customized
>statement, and it is going to be different for the case of existing key
>versus case of the new key.
>Isn't this too much hassle?
>
>Related question. I assumed that prepared statement in Cassandra is there
>for the same reason as in RDBMS, that is, for efficiency. In the above
>scenario, how expensive is it to execute specialized statement for every
>record compare to prepared statement executed multiple times?
>
>If I need to execute those specialized statements, should I still use
>prepared statement or should I just generate a string with everything in
>ascii format?
>
>-----Original Message-----
>From: Roshni Rajagopal [mailto:Roshni.Rajagopal@wal-mart.com]
>Sent: Monday, June 11, 2012 12:58 AM
>To: user@cassandra.apache.org
>Subject: Re: Setting column to null
>
>Would you want to view data like this "there was a key, which had this
>column , but now it does not have any value as of this time."
>
>Unless you specifically want this information, I believe you should just
>delete the column, rather than have an alternate value for NULL or create
>a composite column.
>
>Because in cassandra that¹s the way deletion is dealt with, putting NULLs
>is the way we deal with it in RDBMS because we have a fixed number of
>columns which always have to have some value, even if its NULL, and we
>have to have the same set of columns for every row.
>In Cassandara, we can delete the column, and in most scenarios that¹s
>what we should do, unless we specifically want to preserve some history
>that this column was turned null at this timeŠEach row can have different
>columns.
>
>Regards,
>Roshni
>
>From: Edward Capriolo
><ed...@gmail.com>>
>Reply-To: "user@cassandra.apache.org<ma...@cassandra.apache.org>"
><us...@cassandra.apache.org>>
>To: "user@cassandra.apache.org<ma...@cassandra.apache.org>"
><us...@cassandra.apache.org>>
>Subject: Re: Setting column to null
>
>Your best bet is to define the column as a composite column where one
>part represents is null and the other part is the data.
>
>On Friday, June 8, 2012, shashwat shriparv
><dw...@gmail.com>> wrote:
>> What you can do is you can define some specific variable like
>>"NULLDATA" some thing like that to update in columns that does have value
>>
>>
>> On Fri, Jun 8, 2012 at 11:58 PM, aaron morton
>><aa...@thelastpickle.com>> wrote:
>>
>> You don't nee to set columns to null, delete the column instead.
>> Cheers
>> -----------------
>> Aaron Morton
>> Freelance Developer
>> @aaronmorton
>> http://www.thelastpickle.com
>> On 8/06/2012, at 9:34 AM, Leonid Ilyevsky wrote:
>>
>> Is it possible to explicitly set a column value to null?
>>
>> I see that if insert statement does not include a specific column, that
>>column comes up as null (assuming we are creating a record with new
>>unique key).
>> But if we want to update a record, how we set it to null?
>>
>> Another situation is when I use prepared cql3 statement (in Java) and
>>send parameters when I execute it. If I want to leave some column
>>unassigned, I need a special statement without that column.
>> What I would like is, prepare one statement including all columns, and
>>then be able to set some of them to null. I tried to set corresponding
>>ByteBuffer parameter to null, obviously got an exception.
>> ________________________________
>> This email, along with any attachments, is confidential and may be
>>legally privileged or otherwise protected from disclosure. Any
>>unauthorized dissemination, copying or use of the contents of this email
>>is strictly prohibited and may be in violation of law. If you are not
>>the intended recipient, any disclosure, copying, forwarding or
>>distribution of this email is strictly prohibited and this email and any
>>attachments should be deleted immediately. This email and any
>>attachments do not constitute an offer to sell or a solicitation of an
>>offer to purchase any interest in any investment vehicle sponsored by
>>Moon Capital Management LP (³Moon Capital²). Moon Capital does not
>>provide legal, accounting or tax advice. Any statement regarding legal,
>>accounting or tax matters was not intended or written to be relied upon
>>by any person as advice. Moon Capital does not waive confidentiality or
>>privilege as a result of this email.
>>
>>
>>
>> --
>>
>>
>> ƒ
>>
>> Shashwat Shriparv
>>
>>
>
>This email and any files transmitted with it are confidential and
>intended solely for the individual or entity to whom they are addressed.
>If you have received this email in error destroy it immediately. ***
>Walmart Confidential ***
>
>This email, along with any attachments, is confidential and may be
>legally privileged or otherwise protected from disclosure. Any
>unauthorized dissemination, copying or use of the contents of this email
>is strictly prohibited and may be in violation of law. If you are not the
>intended recipient, any disclosure, copying, forwarding or distribution
>of this email is strictly prohibited and this email and any attachments
>should be deleted immediately.  This email and any attachments do not
>constitute an offer to sell or a solicitation of an offer to purchase any
>interest in any investment vehicle sponsored by Moon Capital Management
>LP (³Moon Capital²). Moon Capital does not provide legal, accounting or
>tax advice. Any statement regarding legal, accounting or tax matters was
>not intended or written to be relied upon by any person as advice. Moon
>Capital does not waive confidentiality or privilege as a result of this
>email.

This email and any files transmitted with it are confidential and intended solely for the individual or entity to whom they are addressed. If you have received this email in error destroy it immediately. *** Walmart Confidential ***

This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately.  This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

Re: Help with configuring replication

Posted by aaron morton <aa...@thelastpickle.com>.
Some docs here http://www.datastax.com/docs/1.0/initialize/index

Cheers


-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 14/06/2012, at 8:14 AM, Leonid Ilyevsky wrote:

> Before going into complex clustering topologies, I would like to try the most simple configuration: just set up two nodes that will completely replicate each other.
> Could somebody tell me how to configure it?
>  
> Thanks!
> 
> This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.


Help with configuring replication

Posted by Leonid Ilyevsky <li...@mooncapital.com>.
Before going into complex clustering topologies, I would like to try the most simple configuration: just set up two nodes that will completely replicate each other.
Could somebody tell me how to configure it?

Thanks!

________________________________
This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP ("Moon Capital"). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

Re: select count(*) returns 10000

Posted by Tamar Fraenkel <ta...@tok-media.com>.
Add "limit N" and it will count more than 10000.
Of course it will be slow when you increase N.

*Tamar Fraenkel *
Senior Software Engineer, TOK Media

[image: Inline image 1]

tamar@tok-media.com
Tel:   +972 2 6409736
Mob:  +972 54 8356490
Fax:   +972 2 5612956





On Tue, Jun 12, 2012 at 10:07 PM, Derek Williams <de...@fyrie.net> wrote:

> It's a known issue, here is a bit extra info on it:
> http://stackoverflow.com/questions/8795923/wrong-count-with-cassandra-cql
>
>
> On Tue, Jun 12, 2012 at 12:40 PM, Leonid Ilyevsky <
> lilyevsky@mooncapital.com> wrote:
>
>> The "select count(*) ..." query returns correct count only if it is <=
>> 10000, otherwise it returns exactly 10000.
>> This happens in both Java API and cqlsh.
>> Can somebody verify?
>>
>> This email, along with any attachments, is confidential and may be
>> legally privileged or otherwise protected from disclosure. Any unauthorized
>> dissemination, copying or use of the contents of this email is strictly
>> prohibited and may be in violation of law. If you are not the intended
>> recipient, any disclosure, copying, forwarding or distribution of this
>> email is strictly prohibited and this email and any attachments should be
>> deleted immediately.  This email and any attachments do not constitute an
>> offer to sell or a solicitation of an offer to purchase any interest in any
>> investment vehicle sponsored by Moon Capital Management LP ("Moon
>> Capital"). Moon Capital does not provide legal, accounting or tax advice.
>> Any statement regarding legal, accounting or tax matters was not intended
>> or written to be relied upon by any person as advice. Moon Capital does not
>> waive confidentiality or privilege as a result of this email.
>>
>
>
>
> --
> Derek Williams
>
>

Re: select count(*) returns 10000

Posted by Derek Williams <de...@fyrie.net>.
It's a known issue, here is a bit extra info on it:
http://stackoverflow.com/questions/8795923/wrong-count-with-cassandra-cql

On Tue, Jun 12, 2012 at 12:40 PM, Leonid Ilyevsky <lilyevsky@mooncapital.com
> wrote:

> The "select count(*) ..." query returns correct count only if it is <=
> 10000, otherwise it returns exactly 10000.
> This happens in both Java API and cqlsh.
> Can somebody verify?
>
> This email, along with any attachments, is confidential and may be legally
> privileged or otherwise protected from disclosure. Any unauthorized
> dissemination, copying or use of the contents of this email is strictly
> prohibited and may be in violation of law. If you are not the intended
> recipient, any disclosure, copying, forwarding or distribution of this
> email is strictly prohibited and this email and any attachments should be
> deleted immediately.  This email and any attachments do not constitute an
> offer to sell or a solicitation of an offer to purchase any interest in any
> investment vehicle sponsored by Moon Capital Management LP ("Moon
> Capital"). Moon Capital does not provide legal, accounting or tax advice.
> Any statement regarding legal, accounting or tax matters was not intended
> or written to be relied upon by any person as advice. Moon Capital does not
> waive confidentiality or privilege as a result of this email.
>



-- 
Derek Williams

select count(*) returns 10000

Posted by Leonid Ilyevsky <li...@mooncapital.com>.
The "select count(*) ..." query returns correct count only if it is <= 10000, otherwise it returns exactly 10000.
This happens in both Java API and cqlsh.
Can somebody verify?

This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately.  This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP ("Moon Capital"). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

RE: Number format in cqlsh

Posted by Leonid Ilyevsky <li...@mooncapital.com>.
Filed the ticket:
Cassandra   CASSANDRA-4336

From: paul cannon [mailto:paul@datastax.com]
Sent: Tuesday, June 12, 2012 12:49 PM
To: user@cassandra.apache.org
Subject: Re: Number format in cqlsh

No, but a way could be added pretty easily. File a ticket on Jira?

p

On Tuesday, June 12, 2012, Leonid Ilyevsky wrote:
Is there a way to control the floating numbers format in the cqlsh output? I need more digits than it gives by default (in my tests, I see only one digit after the point).

This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately.  This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP ("Moon Capital"). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

________________________________
This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

Re: Number format in cqlsh

Posted by paul cannon <pa...@datastax.com>.
No, but a way could be added pretty easily. File a ticket on Jira?

p

On Tuesday, June 12, 2012, Leonid Ilyevsky wrote:

> Is there a way to control the floating numbers format in the cqlsh output?
> I need more digits than it gives by default (in my tests, I see only one
> digit after the point).
>
> This email, along with any attachments, is confidential and may be legally
> privileged or otherwise protected from disclosure. Any unauthorized
> dissemination, copying or use of the contents of this email is strictly
> prohibited and may be in violation of law. If you are not the intended
> recipient, any disclosure, copying, forwarding or distribution of this
> email is strictly prohibited and this email and any attachments should be
> deleted immediately.  This email and any attachments do not constitute an
> offer to sell or a solicitation of an offer to purchase any interest in any
> investment vehicle sponsored by Moon Capital Management LP ("Moon
> Capital"). Moon Capital does not provide legal, accounting or tax advice.
> Any statement regarding legal, accounting or tax matters was not intended
> or written to be relied upon by any person as advice. Moon Capital does not
> waive confidentiality or privilege as a result of this email.
>

Number format in cqlsh

Posted by Leonid Ilyevsky <li...@mooncapital.com>.
Is there a way to control the floating numbers format in the cqlsh output? I need more digits than it gives by default (in my tests, I see only one digit after the point).

This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately.  This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP ("Moon Capital"). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

Re: Setting column to null

Posted by Roshni Rajagopal <Ro...@wal-mart.com>.
Leonid,


Are you using some client for doing these operations..?

Hector is a java client which provides APIs for adding/deleting columns to
a column family in cassandra.
I don¹t think you really need to write your wrapper in this format- you
are restricting the number of columns it can use etc.I suggest your code
can  accept user input to get col family name, operation, keys  , and
operation, and accordingly call the appropriate hector API for
adding/deleting data.


Regards,
Roshni


On 11/06/12 7:20 PM, "Leonid Ilyevsky" <li...@mooncapital.com> wrote:

>Thanks, I understand what you are telling me. Obviously deleting the
>column is the proper way to do this in Cassandra.
>What I was looking for, is some convenient wrapper on top of that which
>will do it for me. Here is my scenario.
>
>I have a function that takes a record to be saved in Cassandra (array of
>objects, or Map<String, Object>). Let say, it can have up to 8 columns. I
>prepare a statement like this:
>
>Insert into <table> values(?, ?, ?, ?, ?, ?, ?, ?)
>
>If I somehow could put null when I execute it, it would be enough to
>prepare that statement once and execute it multiple times. I would then
>expect that when some element is null, the corresponding column is not
>inserted (for the new key) or deleted (for the existing key).
>The way it is now, in my code I have to examine which columns are present
>and which are not, depending on that I have to generate customized
>statement, and it is going to be different for the case of existing key
>versus case of the new key.
>Isn't this too much hassle?
>
>Related question. I assumed that prepared statement in Cassandra is there
>for the same reason as in RDBMS, that is, for efficiency. In the above
>scenario, how expensive is it to execute specialized statement for every
>record compare to prepared statement executed multiple times?
>
>If I need to execute those specialized statements, should I still use
>prepared statement or should I just generate a string with everything in
>ascii format?
>
>-----Original Message-----
>From: Roshni Rajagopal [mailto:Roshni.Rajagopal@wal-mart.com]
>Sent: Monday, June 11, 2012 12:58 AM
>To: user@cassandra.apache.org
>Subject: Re: Setting column to null
>
>Would you want to view data like this "there was a key, which had this
>column , but now it does not have any value as of this time."
>
>Unless you specifically want this information, I believe you should just
>delete the column, rather than have an alternate value for NULL or create
>a composite column.
>
>Because in cassandra that¹s the way deletion is dealt with, putting NULLs
>is the way we deal with it in RDBMS because we have a fixed number of
>columns which always have to have some value, even if its NULL, and we
>have to have the same set of columns for every row.
>In Cassandara, we can delete the column, and in most scenarios that¹s
>what we should do, unless we specifically want to preserve some history
>that this column was turned null at this timeŠEach row can have different
>columns.
>
>Regards,
>Roshni
>
>From: Edward Capriolo
><ed...@gmail.com>>
>Reply-To: "user@cassandra.apache.org<ma...@cassandra.apache.org>"
><us...@cassandra.apache.org>>
>To: "user@cassandra.apache.org<ma...@cassandra.apache.org>"
><us...@cassandra.apache.org>>
>Subject: Re: Setting column to null
>
>Your best bet is to define the column as a composite column where one
>part represents is null and the other part is the data.
>
>On Friday, June 8, 2012, shashwat shriparv
><dw...@gmail.com>> wrote:
>> What you can do is you can define some specific variable like
>>"NULLDATA" some thing like that to update in columns that does have value
>>
>>
>> On Fri, Jun 8, 2012 at 11:58 PM, aaron morton
>><aa...@thelastpickle.com>> wrote:
>>
>> You don't nee to set columns to null, delete the column instead.
>> Cheers
>> -----------------
>> Aaron Morton
>> Freelance Developer
>> @aaronmorton
>> http://www.thelastpickle.com
>> On 8/06/2012, at 9:34 AM, Leonid Ilyevsky wrote:
>>
>> Is it possible to explicitly set a column value to null?
>>
>> I see that if insert statement does not include a specific column, that
>>column comes up as null (assuming we are creating a record with new
>>unique key).
>> But if we want to update a record, how we set it to null?
>>
>> Another situation is when I use prepared cql3 statement (in Java) and
>>send parameters when I execute it. If I want to leave some column
>>unassigned, I need a special statement without that column.
>> What I would like is, prepare one statement including all columns, and
>>then be able to set some of them to null. I tried to set corresponding
>>ByteBuffer parameter to null, obviously got an exception.
>> ________________________________
>> This email, along with any attachments, is confidential and may be
>>legally privileged or otherwise protected from disclosure. Any
>>unauthorized dissemination, copying or use of the contents of this email
>>is strictly prohibited and may be in violation of law. If you are not
>>the intended recipient, any disclosure, copying, forwarding or
>>distribution of this email is strictly prohibited and this email and any
>>attachments should be deleted immediately. This email and any
>>attachments do not constitute an offer to sell or a solicitation of an
>>offer to purchase any interest in any investment vehicle sponsored by
>>Moon Capital Management LP (³Moon Capital²). Moon Capital does not
>>provide legal, accounting or tax advice. Any statement regarding legal,
>>accounting or tax matters was not intended or written to be relied upon
>>by any person as advice. Moon Capital does not waive confidentiality or
>>privilege as a result of this email.
>>
>>
>>
>> --
>>
>>
>> ƒ
>>
>> Shashwat Shriparv
>>
>>
>
>This email and any files transmitted with it are confidential and
>intended solely for the individual or entity to whom they are addressed.
>If you have received this email in error destroy it immediately. ***
>Walmart Confidential ***
>
>This email, along with any attachments, is confidential and may be
>legally privileged or otherwise protected from disclosure. Any
>unauthorized dissemination, copying or use of the contents of this email
>is strictly prohibited and may be in violation of law. If you are not the
>intended recipient, any disclosure, copying, forwarding or distribution
>of this email is strictly prohibited and this email and any attachments
>should be deleted immediately.  This email and any attachments do not
>constitute an offer to sell or a solicitation of an offer to purchase any
>interest in any investment vehicle sponsored by Moon Capital Management
>LP (³Moon Capital²). Moon Capital does not provide legal, accounting or
>tax advice. Any statement regarding legal, accounting or tax matters was
>not intended or written to be relied upon by any person as advice. Moon
>Capital does not waive confidentiality or privilege as a result of this
>email.

This email and any files transmitted with it are confidential and intended solely for the individual or entity to whom they are addressed. If you have received this email in error destroy it immediately. *** Walmart Confidential ***

RE: Setting column to null

Posted by Leonid Ilyevsky <li...@mooncapital.com>.
Thanks, I understand what you are telling me. Obviously deleting the column is the proper way to do this in Cassandra.
What I was looking for, is some convenient wrapper on top of that which will do it for me. Here is my scenario.

I have a function that takes a record to be saved in Cassandra (array of objects, or Map<String, Object>). Let say, it can have up to 8 columns. I prepare a statement like this:

Insert into <table> values(?, ?, ?, ?, ?, ?, ?, ?)

If I somehow could put null when I execute it, it would be enough to prepare that statement once and execute it multiple times. I would then expect that when some element is null, the corresponding column is not inserted (for the new key) or deleted (for the existing key).
The way it is now, in my code I have to examine which columns are present and which are not, depending on that I have to generate customized statement, and it is going to be different for the case of existing key versus case of the new key.
Isn't this too much hassle?

Related question. I assumed that prepared statement in Cassandra is there for the same reason as in RDBMS, that is, for efficiency. In the above scenario, how expensive is it to execute specialized statement for every record compare to prepared statement executed multiple times?

If I need to execute those specialized statements, should I still use prepared statement or should I just generate a string with everything in ascii format?

-----Original Message-----
From: Roshni Rajagopal [mailto:Roshni.Rajagopal@wal-mart.com]
Sent: Monday, June 11, 2012 12:58 AM
To: user@cassandra.apache.org
Subject: Re: Setting column to null

Would you want to view data like this "there was a key, which had this column , but now it does not have any value as of this time."

Unless you specifically want this information, I believe you should just delete the column, rather than have an alternate value for NULL or create a composite column.

Because in cassandra that’s the way deletion is dealt with, putting NULLs is the way we deal with it in RDBMS because we have a fixed number of columns which always have to have some value, even if its NULL, and we have to have the same set of columns for every row.
In Cassandara, we can delete the column, and in most scenarios that’s what we should do, unless we specifically want to preserve some history that this column was turned null at this time…Each row can have different columns.

Regards,
Roshni

From: Edward Capriolo <ed...@gmail.com>>
Reply-To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
Subject: Re: Setting column to null

Your best bet is to define the column as a composite column where one part represents is null and the other part is the data.

On Friday, June 8, 2012, shashwat shriparv <dw...@gmail.com>> wrote:
> What you can do is you can define some specific variable like "NULLDATA" some thing like that to update in columns that does have value
>
>
> On Fri, Jun 8, 2012 at 11:58 PM, aaron morton <aa...@thelastpickle.com>> wrote:
>
> You don't nee to set columns to null, delete the column instead.
> Cheers
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
> On 8/06/2012, at 9:34 AM, Leonid Ilyevsky wrote:
>
> Is it possible to explicitly set a column value to null?
>
> I see that if insert statement does not include a specific column, that column comes up as null (assuming we are creating a record with new unique key).
> But if we want to update a record, how we set it to null?
>
> Another situation is when I use prepared cql3 statement (in Java) and send parameters when I execute it. If I want to leave some column unassigned, I need a special statement without that column.
> What I would like is, prepare one statement including all columns, and then be able to set some of them to null. I tried to set corresponding ByteBuffer parameter to null, obviously got an exception.
> ________________________________
> This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.
>
>
>
> --
>
>
> ∞
>
> Shashwat Shriparv
>
>

This email and any files transmitted with it are confidential and intended solely for the individual or entity to whom they are addressed. If you have received this email in error destroy it immediately. *** Walmart Confidential ***

This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately.  This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

Re: Setting column to null

Posted by Roshni Rajagopal <Ro...@wal-mart.com>.
Would you want to view data like this "there was a key, which had this column , but now it does not have any value as of this time."

Unless you specifically want this information, I believe you should just delete the column, rather than have an alternate value for NULL or create a composite column.

Because in cassandra that’s the way deletion is dealt with, putting NULLs is the way we deal with it in RDBMS because we have a fixed number of columns which always have to have some value, even if its NULL, and we have to have the same set of columns for every row.
In Cassandara, we can delete the column, and in most scenarios that’s what we should do, unless we specifically want to preserve some history that this column was turned null at this time…Each row can have different columns.

Regards,
Roshni

From: Edward Capriolo <ed...@gmail.com>>
Reply-To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
Subject: Re: Setting column to null

Your best bet is to define the column as a composite column where one part represents is null and the other part is the data.

On Friday, June 8, 2012, shashwat shriparv <dw...@gmail.com>> wrote:
> What you can do is you can define some specific variable like "NULLDATA" some thing like that to update in columns that does have value
>
>
> On Fri, Jun 8, 2012 at 11:58 PM, aaron morton <aa...@thelastpickle.com>> wrote:
>
> You don't nee to set columns to null, delete the column instead.
> Cheers
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
> On 8/06/2012, at 9:34 AM, Leonid Ilyevsky wrote:
>
> Is it possible to explicitly set a column value to null?
>
> I see that if insert statement does not include a specific column, that column comes up as null (assuming we are creating a record with new unique key).
> But if we want to update a record, how we set it to null?
>
> Another situation is when I use prepared cql3 statement (in Java) and send parameters when I execute it. If I want to leave some column unassigned, I need a special statement without that column.
> What I would like is, prepare one statement including all columns, and then be able to set some of them to null. I tried to set corresponding ByteBuffer parameter to null, obviously got an exception.
> ________________________________
> This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.
>
>
>
> --
>
>
> ∞
>
> Shashwat Shriparv
>
>

This email and any files transmitted with it are confidential and intended solely for the individual or entity to whom they are addressed. If you have received this email in error destroy it immediately. *** Walmart Confidential ***

Re: Setting column to null

Posted by Edward Capriolo <ed...@gmail.com>.
Your best bet is to define the column as a composite column where one part
represents is null and the other part is the data.

On Friday, June 8, 2012, shashwat shriparv <dw...@gmail.com>
wrote:
> What you can do is you can define some specific variable like "NULLDATA"
some thing like that to update in columns that does have value
>
>
> On Fri, Jun 8, 2012 at 11:58 PM, aaron morton <aa...@thelastpickle.com>
wrote:
>
> You don't nee to set columns to null, delete the column instead.
> Cheers
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
> On 8/06/2012, at 9:34 AM, Leonid Ilyevsky wrote:
>
> Is it possible to explicitly set a column value to null?
>
> I see that if insert statement does not include a specific column, that
column comes up as null (assuming we are creating a record with new unique
key).
> But if we want to update a record, how we set it to null?
>
> Another situation is when I use prepared cql3 statement (in Java) and
send parameters when I execute it. If I want to leave some column
unassigned, I need a special statement without that column.
> What I would like is, prepare one statement including all columns, and
then be able to set some of them to null. I tried to set corresponding
ByteBuffer parameter to null, obviously got an exception.
> ________________________________
> This email, along with any attachments, is confidential and may be
legally privileged or otherwise protected from disclosure. Any unauthorized
dissemination, copying or use of the contents of this email is strictly
prohibited and may be in violation of law. If you are not the intended
recipient, any disclosure, copying, forwarding or distribution of this
email is strictly prohibited and this email and any attachments should be
deleted immediately. This email and any attachments do not constitute an
offer to sell or a solicitation of an offer to purchase any interest in any
investment vehicle sponsored by Moon Capital Management LP (“Moon
Capital”). Moon Capital does not provide legal, accounting or tax advice.
Any statement regarding legal, accounting or tax matters was not intended
or written to be relied upon by any person as advice. Moon Capital does not
waive confidentiality or privilege as a result of this email.
>
>
>
> --
>
>
> ∞
>
> Shashwat Shriparv
>
>

Re: Setting column to null

Posted by shashwat shriparv <dw...@gmail.com>.
What you can do is you can define some specific variable like "NULLDATA"
some thing like that to update in columns that does have value



On Fri, Jun 8, 2012 at 11:58 PM, aaron morton <aa...@thelastpickle.com>wrote:

> You don't nee to set columns to null, delete the column instead.
>
> Cheers
>
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 8/06/2012, at 9:34 AM, Leonid Ilyevsky wrote:
>
> Is it possible to explicitly set a column value to null?****
> ** **
> I see that if insert statement does not include a specific column, that
> column comes up as null (assuming we are creating a record with new unique
> key).****
> But if we want to update a record, how we set it to null?****
> ** **
> Another situation is when I use prepared cql3 statement (in Java) and send
> parameters when I execute it. If I want to leave some column unassigned, I
> need a special statement without that column.****
> What I would like is, prepare one statement including all columns, and
> then be able to set some of them to null. I tried to set corresponding
> ByteBuffer parameter to null, obviously got an exception.****
>
> ------------------------------
> This email, along with any attachments, is confidential and may be legally
> privileged or otherwise protected from disclosure. Any unauthorized
> dissemination, copying or use of the contents of this email is strictly
> prohibited and may be in violation of law. If you are not the intended
> recipient, any disclosure, copying, forwarding or distribution of this
> email is strictly prohibited and this email and any attachments should be
> deleted immediately. This email and any attachments do not constitute an
> offer to sell or a solicitation of an offer to purchase any interest in any
> investment vehicle sponsored by Moon Capital Management LP (“Moon
> Capital”). Moon Capital does not provide legal, accounting or tax advice.
> Any statement regarding legal, accounting or tax matters was not intended
> or written to be relied upon by any person as advice. Moon Capital does not
> waive confidentiality or privilege as a result of this email.
>
>
>


-- 


∞
Shashwat Shriparv

Re: Setting column to null

Posted by aaron morton <aa...@thelastpickle.com>.
You don't nee to set columns to null, delete the column instead.

Cheers

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 8/06/2012, at 9:34 AM, Leonid Ilyevsky wrote:

> Is it possible to explicitly set a column value to null?
>  
> I see that if insert statement does not include a specific column, that column comes up as null (assuming we are creating a record with new unique key).
> But if we want to update a record, how we set it to null?
>  
> Another situation is when I use prepared cql3 statement (in Java) and send parameters when I execute it. If I want to leave some column unassigned, I need a special statement without that column.
> What I would like is, prepare one statement including all columns, and then be able to set some of them to null. I tried to set corresponding ByteBuffer parameter to null, obviously got an exception.
> 
> This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.