cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aleksey Yeschenko (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CASSANDRA-5648) Cassandra: Insert of null value not possible with CQL3?
Date Tue, 18 Jun 2013 12:59:20 GMT

     [ https://issues.apache.org/jira/browse/CASSANDRA-5648?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Aleksey Yeschenko resolved CASSANDRA-5648.
------------------------------------------

    Resolution: Not A Problem

Technically, column value can't be null in Thrift. It can be set to an empty byte buffer,
and it's not the same as null (there is no way to distinguish between an empty blob/string
and 'null', for example - all map to an empty byte buffer).

bq. Inserting an empty String works fine, but this seems a bit bloated.
It's not bloated, it's actually what you want. And for blob columns, inserting 0x would be
the equivalent.

In CQL3, however, there *is* null, and it already represents something - absence of a cell.
And using null in INSERT or UPDATE maps to DELETE of the whole cell. Overloading it for COMPACT
STORAGE to mean 'empty byte buffer value' would be inconsistent and confusing - we don't need
two kinds of null.

That said, it's true that Thrift API allows something that CQL3 does not - namely, setting
the value to an empty byte buffer for int/float/etc. values (which wasn't such a good idea,
probably). You can do the same in CLQ3 using prepared statements, so there is a workaround
(for strings and blobs you can just use '' and 0x, respectively).
                
> Cassandra: Insert of null value not possible with CQL3?
> -------------------------------------------------------
>
>                 Key: CASSANDRA-5648
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-5648
>             Project: Cassandra
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 1.2.0
>            Reporter: Tobias Schlottke
>            Assignee: Aleksey Yeschenko
>             Fix For: 1.2.6
>
>
> Hi there,
> I'm trying to migrate a project from thrift to cql3/java driver and I'm experiencing
a strange problem.
> Schema:
> {code}
> CREATE TABLE foo (
>   key ascii,
>   column1 ascii,
>   foo ascii,
>   PRIMARY KEY (key, column1)
> ) WITH COMPACT STORAGE;
> {code}
> The table just consists of a primary key and a value, sometimes all the information lies
in the key though, so the value is not needed.
> Through the thrift interface, it just works fine to leave out "foo".
> Executing this query:
> {code}
> INSERT INTO foo(key, column1) VALUES ('test', 'test2');
> {code}
> Fails with
> "Bad Request: Missing mandatory column foo"
> though.
> Explicitly inserting "null" as a value does not store the column / deletes the old one
with a "null" value inserted through thrift.
> Inserting an empty String works fine, but this seems a bit bloated.
> Is this intended to (not) work this way?
> Best,
> Tobias

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message