You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Ian Rose <ia...@fullstory.com> on 2014/08/26 21:12:15 UTC
are dynamic columns supported at all in CQL 3?
Is it possible in CQL to create a table that supports dynamic column names?
I am using C* v2.0.9, which I assume implies CQL version 3.
This page appears to show that this was supported in CQL 2 with the 'with
comparator' and 'with default_validation' options but that CQL 3 does not
support this: http://www.datastax.com/dev/blog/whats-new-in-cql-3-0
Am I understanding that right? If so, what is my best course of action?
Create the table using the cassandra-cli tool?
Thanks,
- Ian
Re: are dynamic columns supported at all in CQL 3?
Posted by Robert Coli <rc...@eventbrite.com>.
On Tue, Aug 26, 2014 at 12:14 PM, Shane Hansen <sh...@gmail.com>
wrote:
> Does this answer your question Ian?
> http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows
>
If dissembling can be considered to answer a question...
"A common misunderstanding is that CQL does not support dynamic columns or
wide rows. On the contrary, CQL was designed to support everything you can
do with the Thrift model, but make it easier and more accessible."
The sentence makes it clear that CQL must not "support" "dynamic columns",
because it instead supports "everything you can do" with them.
tl;dr :
-------
If OP is asking if CQL3 supports actual "dynamic columns" as they existed
in CQL2 and thrift, the answer is : "no".
If OP is asking if one can use CQL3's E-A-V like scheme to achieve a
similar [1] result, the answer is : "yes".
=Rob
[1] http://www.edwardcapriolo.com/roller/edwardcapriolo/entry/legacy_tables
Re: are dynamic columns supported at all in CQL 3?
Posted by Ian Rose <ia...@fullstory.com>.
Deepak -
Yes, you are indeed right. I must admit I am still trying to learn what
queries can and cannot be performed in Cassandra and I didn't realize that
you could query on a non-fully-specified primary key, as long as you *do* fully
qualify the partition key.
Cheers,
Ian
On Wed, Aug 27, 2014 at 11:31 AM, Deepak Shetty <sh...@gmail.com> wrote:
> " Using the post's example, consider the query of "get all readings for
> sensor 1". With dynamic columns, the query is just "select * from data
> where sensor_id=1". In CQL, not only does this take N different queries
> (one per sample) but you have to explicitly know the collected_at values to
> query for. Right?"
> This does work in CQL (v3.1.1 , tried on Cassandra 2.0.4)
>
> cqlsh:playlist> CREATE TABLE data (
> ... sensor_id int,
> ... collected_at timestamp,
> ... volts float,
> ... PRIMARY KEY (sensor_id, collected_at)
> ... ) WITH COMPACT STORAGE;
> cqlsh:playlist> insert into data(sensor_id,collected_at,volts) values
> (1,'2014-0
> 5-01 00:00:00',1.2);
> cqlsh:playlist> insert into data(sensor_id,collected_at,volts) values
> (1,'2014-0
> 5-02 00:00:00',1.3);
> cqlsh:playlist> insert into data(sensor_id,collected_at,volts) values
> (1,'2014-0
> 5-03 00:00:00',1.4);
> cqlsh:playlist> insert into data(sensor_id,collected_at,volts) values
> (2,'2014-0
> 5-03 00:00:00',2.4);
> cqlsh:playlist> select * from data;
>
> sensor_id | collected_at | volts
> -----------+------------------------------------------+-------
> 1 | 2014-05-01 00:00:00Pacific Daylight Time | 1.2
> 1 | 2014-05-02 00:00:00Pacific Daylight Time | 1.3
> 1 | 2014-05-03 00:00:00Pacific Daylight Time | 1.4
> 2 | 2014-05-03 00:00:00Pacific Daylight Time | 2.4
>
> (4 rows)
>
> cqlsh:playlist> select * from data where sensor_id=1;
>
> sensor_id | collected_at | volts
> -----------+------------------------------------------+-------
> 1 | 2014-05-01 00:00:00Pacific Daylight Time | 1.2
> 1 | 2014-05-02 00:00:00Pacific Daylight Time | 1.3
> 1 | 2014-05-03 00:00:00Pacific Daylight Time | 1.4
>
> (3 rows)
>
> cqlsh:playlist>
>
>
>
>
>
>
> On Tue, Aug 26, 2014 at 12:33 PM, Ian Rose <ia...@fullstory.com> wrote:
>
>> Unfortunately, no. I've read that and the solution presented only works
>> in limited scenarios. Using the post's example, consider the query of "get
>> all readings for sensor 1". With dynamic columns, the query is just
>> "select * from data where sensor_id=1". In CQL, not only does this take N
>> different queries (one per sample) but you have to explicitly know the
>> collected_at values to query for. Right?
>>
>> The other suggestion, to use collections (such as a map), again works in
>> some circumstances, but not all. In particular, each item in a collection
>> is limited to 64k bytes which is not something we want to be limited to (we
>> are storing byte arrays that occasionally exceed this size).
>>
>>
>>
>> On Tue, Aug 26, 2014 at 3:14 PM, Shane Hansen <sh...@gmail.com>
>> wrote:
>>
>>> Does this answer your question Ian?
>>>
>>> http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows
>>>
>>>
>>>
>>> On Tue, Aug 26, 2014 at 1:12 PM, Ian Rose <ia...@fullstory.com> wrote:
>>>
>>>> Is it possible in CQL to create a table that supports dynamic column
>>>> names? I am using C* v2.0.9, which I assume implies CQL version 3.
>>>>
>>>> This page appears to show that this was supported in CQL 2 with the
>>>> 'with comparator' and 'with default_validation' options but that CQL 3 does
>>>> not support this: http://www.datastax.com/dev/blog/whats-new-in-cql-3-0
>>>>
>>>> Am I understanding that right? If so, what is my best course of
>>>> action? Create the table using the cassandra-cli tool?
>>>>
>>>> Thanks,
>>>> - Ian
>>>>
>>>>
>>>
>>
>
Re: are dynamic columns supported at all in CQL 3?
Posted by Deepak Shetty <sh...@gmail.com>.
" Using the post's example, consider the query of "get all readings for
sensor 1". With dynamic columns, the query is just "select * from data
where sensor_id=1". In CQL, not only does this take N different queries
(one per sample) but you have to explicitly know the collected_at values to
query for. Right?"
This does work in CQL (v3.1.1 , tried on Cassandra 2.0.4)
cqlsh:playlist> CREATE TABLE data (
... sensor_id int,
... collected_at timestamp,
... volts float,
... PRIMARY KEY (sensor_id, collected_at)
... ) WITH COMPACT STORAGE;
cqlsh:playlist> insert into data(sensor_id,collected_at,volts) values
(1,'2014-0
5-01 00:00:00',1.2);
cqlsh:playlist> insert into data(sensor_id,collected_at,volts) values
(1,'2014-0
5-02 00:00:00',1.3);
cqlsh:playlist> insert into data(sensor_id,collected_at,volts) values
(1,'2014-0
5-03 00:00:00',1.4);
cqlsh:playlist> insert into data(sensor_id,collected_at,volts) values
(2,'2014-0
5-03 00:00:00',2.4);
cqlsh:playlist> select * from data;
sensor_id | collected_at | volts
-----------+------------------------------------------+-------
1 | 2014-05-01 00:00:00Pacific Daylight Time | 1.2
1 | 2014-05-02 00:00:00Pacific Daylight Time | 1.3
1 | 2014-05-03 00:00:00Pacific Daylight Time | 1.4
2 | 2014-05-03 00:00:00Pacific Daylight Time | 2.4
(4 rows)
cqlsh:playlist> select * from data where sensor_id=1;
sensor_id | collected_at | volts
-----------+------------------------------------------+-------
1 | 2014-05-01 00:00:00Pacific Daylight Time | 1.2
1 | 2014-05-02 00:00:00Pacific Daylight Time | 1.3
1 | 2014-05-03 00:00:00Pacific Daylight Time | 1.4
(3 rows)
cqlsh:playlist>
On Tue, Aug 26, 2014 at 12:33 PM, Ian Rose <ia...@fullstory.com> wrote:
> Unfortunately, no. I've read that and the solution presented only works
> in limited scenarios. Using the post's example, consider the query of "get
> all readings for sensor 1". With dynamic columns, the query is just
> "select * from data where sensor_id=1". In CQL, not only does this take N
> different queries (one per sample) but you have to explicitly know the
> collected_at values to query for. Right?
>
> The other suggestion, to use collections (such as a map), again works in
> some circumstances, but not all. In particular, each item in a collection
> is limited to 64k bytes which is not something we want to be limited to (we
> are storing byte arrays that occasionally exceed this size).
>
>
>
> On Tue, Aug 26, 2014 at 3:14 PM, Shane Hansen <sh...@gmail.com>
> wrote:
>
>> Does this answer your question Ian?
>>
>> http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows
>>
>>
>>
>> On Tue, Aug 26, 2014 at 1:12 PM, Ian Rose <ia...@fullstory.com> wrote:
>>
>>> Is it possible in CQL to create a table that supports dynamic column
>>> names? I am using C* v2.0.9, which I assume implies CQL version 3.
>>>
>>> This page appears to show that this was supported in CQL 2 with the
>>> 'with comparator' and 'with default_validation' options but that CQL 3 does
>>> not support this: http://www.datastax.com/dev/blog/whats-new-in-cql-3-0
>>>
>>> Am I understanding that right? If so, what is my best course of action?
>>> Create the table using the cassandra-cli tool?
>>>
>>> Thanks,
>>> - Ian
>>>
>>>
>>
>
Re: are dynamic columns supported at all in CQL 3?
Posted by Ian Rose <ia...@fullstory.com>.
Unfortunately, no. I've read that and the solution presented only works in
limited scenarios. Using the post's example, consider the query of "get
all readings for sensor 1". With dynamic columns, the query is just
"select * from data where sensor_id=1". In CQL, not only does this take N
different queries (one per sample) but you have to explicitly know the
collected_at values to query for. Right?
The other suggestion, to use collections (such as a map), again works in
some circumstances, but not all. In particular, each item in a collection
is limited to 64k bytes which is not something we want to be limited to (we
are storing byte arrays that occasionally exceed this size).
On Tue, Aug 26, 2014 at 3:14 PM, Shane Hansen <sh...@gmail.com>
wrote:
> Does this answer your question Ian?
> http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows
>
>
>
> On Tue, Aug 26, 2014 at 1:12 PM, Ian Rose <ia...@fullstory.com> wrote:
>
>> Is it possible in CQL to create a table that supports dynamic column
>> names? I am using C* v2.0.9, which I assume implies CQL version 3.
>>
>> This page appears to show that this was supported in CQL 2 with the 'with
>> comparator' and 'with default_validation' options but that CQL 3 does not
>> support this: http://www.datastax.com/dev/blog/whats-new-in-cql-3-0
>>
>> Am I understanding that right? If so, what is my best course of action?
>> Create the table using the cassandra-cli tool?
>>
>> Thanks,
>> - Ian
>>
>>
>
Re: are dynamic columns supported at all in CQL 3?
Posted by Shane Hansen <sh...@gmail.com>.
Does this answer your question Ian?
http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows
On Tue, Aug 26, 2014 at 1:12 PM, Ian Rose <ia...@fullstory.com> wrote:
> Is it possible in CQL to create a table that supports dynamic column
> names? I am using C* v2.0.9, which I assume implies CQL version 3.
>
> This page appears to show that this was supported in CQL 2 with the 'with
> comparator' and 'with default_validation' options but that CQL 3 does not
> support this: http://www.datastax.com/dev/blog/whats-new-in-cql-3-0
>
> Am I understanding that right? If so, what is my best course of action?
> Create the table using the cassandra-cli tool?
>
> Thanks,
> - Ian
>
>