You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cassandra.apache.org by Duarte Nunes <du...@scylladb.com> on 2018/03/24 00:38:21 UTC

Empty partition keys allowed in MV, but not in normal table

Hi,

Given the following table:

cqlsh> create keyspace ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
cqlsh> create table t (p text, c int, v text, primary key (p));
cqlsh> use ks;

The following fails:

cqlsh:ks> insert into t (p, c, v) values ('', 2, '');
InvalidRequest: Error from server: code=2200 [Invalid query] message="Key may not be empty"

However, MVs don't appear to have this restriction:

create materialized view mv as select * from t where v is not null and p is not null and c is not null primary key (v, p);
insert into t (p, c, v) values ('a', 2, '');
select * from mv;

  v | p | c
---+---+---
    | a | 2

I guess this is because an empty value can't be distinguished from null at the protocol level, but this distinction can 
be made internally.

I think the behavior should be made consistent, if nothing else because querying the MV for the empty key is impossible:

cqlsh:ks> select * from mv where v = '';
InvalidRequest: Error from server: code=2200 [Invalid query] message="Key may not be empty"

Thoughts?

Thanks,
Duarte


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cassandra.apache.org
For additional commands, e-mail: dev-help@cassandra.apache.org


Re: Re: Empty partition keys allowed in MV, but not in normal table

Posted by Duarte Nunes <du...@scylladb.com>.
Created https://issues.apache.org/jira/browse/CASSANDRA-14345

On 25/03/2018 22:05, kurt greaves wrote:
> Yeah definitely a problem there. Can you create a JIRA for it?
>
> On Sat., 24 Mar. 2018, 11:00 Duarte Nunes, <du...@scylladb.com> wrote:
>
>> Hi,
>>
>> Given the following table:
>>
>> cqlsh> create keyspace ks WITH replication = {'class': 'SimpleStrategy',
>> 'replication_factor': 1};
>> cqlsh> create table t (p text, c int, v text, primary key (p));
>> cqlsh> use ks;
>>
>> The following fails:
>>
>> cqlsh:ks> insert into t (p, c, v) values ('', 2, '');
>> InvalidRequest: Error from server: code=2200 [Invalid query] message="Key
>> may not be empty"
>>
>> However, MVs don't appear to have this restriction:
>>
>> create materialized view mv as select * from t where v is not null and p
>> is not null and c is not null primary key (v, p);
>> insert into t (p, c, v) values ('a', 2, '');
>> select * from mv;
>>
>>    v | p | c
>> ---+---+---
>>      | a | 2
>>
>> I guess this is because an empty value can't be distinguished from null at
>> the protocol level, but this distinction can
>> be made internally.
>>
>> I think the behavior should be made consistent, if nothing else because
>> querying the MV for the empty key is impossible:
>>
>> cqlsh:ks> select * from mv where v = '';
>> InvalidRequest: Error from server: code=2200 [Invalid query] message="Key
>> may not be empty"
>>
>> Thoughts?
>>
>> Thanks,
>> Duarte
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@cassandra.apache.org
>> For additional commands, e-mail: dev-help@cassandra.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cassandra.apache.org
For additional commands, e-mail: dev-help@cassandra.apache.org


Re: Empty partition keys allowed in MV, but not in normal table

Posted by kurt greaves <ku...@instaclustr.com>.
Yeah definitely a problem there. Can you create a JIRA for it?

On Sat., 24 Mar. 2018, 11:00 Duarte Nunes, <du...@scylladb.com> wrote:

> Hi,
>
> Given the following table:
>
> cqlsh> create keyspace ks WITH replication = {'class': 'SimpleStrategy',
> 'replication_factor': 1};
> cqlsh> create table t (p text, c int, v text, primary key (p));
> cqlsh> use ks;
>
> The following fails:
>
> cqlsh:ks> insert into t (p, c, v) values ('', 2, '');
> InvalidRequest: Error from server: code=2200 [Invalid query] message="Key
> may not be empty"
>
> However, MVs don't appear to have this restriction:
>
> create materialized view mv as select * from t where v is not null and p
> is not null and c is not null primary key (v, p);
> insert into t (p, c, v) values ('a', 2, '');
> select * from mv;
>
>   v | p | c
> ---+---+---
>     | a | 2
>
> I guess this is because an empty value can't be distinguished from null at
> the protocol level, but this distinction can
> be made internally.
>
> I think the behavior should be made consistent, if nothing else because
> querying the MV for the empty key is impossible:
>
> cqlsh:ks> select * from mv where v = '';
> InvalidRequest: Error from server: code=2200 [Invalid query] message="Key
> may not be empty"
>
> Thoughts?
>
> Thanks,
> Duarte
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@cassandra.apache.org
> For additional commands, e-mail: dev-help@cassandra.apache.org
>
>