In the interest of education and discussion.

I didn't mean to say CQL3 doesn't support dynamic columns. The example from
the page shows default type defined in the create statement.

create column family data
with key_validation_class=Int32Type
 and comparator=DateType
 and default_validation_class=FloatType;


If I try to insert a dynamic column that uses double for column name and
string for column value, it will throw an error. The kind of use case I'm
talking about defines a minimum number of static columns. Most of the
columns that are added at runtime are different name and value type. This
is specific to my use case.

Having said that, I believe it "would" be possible to provide that kind of
feature in CQL, but the trade off is it deviates from SQL. The grammar
would have to allow type declaration in the columns list and functions in
the values. Something like

insert into mytable (KEY, doubleType(newcol1), string(newcol2)) values
('abc123', "some string", double(102.211))

doubleType(newcol1) and string(newcol2) are dynamic columns.

I know many people find thrift hard to grok and struggle with it, but I'm a
firm believer in taking time to learn. Every developer should take time to
read cassandra source code and the source code for the driver they're using.



On Fri, Aug 30, 2013 at 2:18 PM, Jonathan Ellis <jbel...@gmail.com> wrote:

> http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows
>
>
> On Fri, Aug 30, 2013 at 12:53 PM, Peter Lin <wool...@gmail.com> wrote:
>
>>
>> my bias perspective, I find the sweet spot is thrift for insert/update
>> and CQL for select queries.
>>
>> CQL is too limiting and negates the power of storing arbitrary data types
>> in dynamic columns.
>>
>>
>> On Fri, Aug 30, 2013 at 1:45 PM, Jon Haddad <j...@jonhaddad.com> wrote:
>>
>>> If you're going to work with CQL, work with CQL.  If you're going to
>>> work with Thrift, work with Thrift.  Don't mix.
>>>
>>> On Aug 30, 2013, at 10:38 AM, Vivek Mishra <mishra.v...@gmail.com>
>>> wrote:
>>>
>>> Hi,
>>> If i a create a table with CQL3 as
>>>
>>> create table user(user_id text PRIMARY KEY, first_name text, last_name
>>> text, emailid text);
>>>
>>> and create index as:
>>> create index on user(first_name);
>>>
>>> then inserted some data as:
>>> insert into user(user_id,first_name,last_name,"emailId")
>>> values('@mevivs','vivek','mishra','vivek.mis...@impetus.co.in');
>>>
>>>
>>> Then if update same column family using Cassandra-cli as:
>>>
>>> update column family user with key_validation_class='UTF8Type' and
>>> column_metadata=[{column_name:last_name, validation_class:'UTF8Type',
>>> index_type:KEYS},{column_name:first_name, validation_class:'UTF8Type',
>>> index_type:KEYS}];
>>>
>>>
>>> Now if i connect via cqlsh and explore user table, i can see column
>>> first_name,last_name are not part of table structure anymore. Here is the
>>> output:
>>>
>>> CREATE TABLE user (
>>>   key text PRIMARY KEY
>>> ) WITH
>>>   bloom_filter_fp_chance=0.010000 AND
>>>   caching='KEYS_ONLY' AND
>>>   comment='' AND
>>>   dclocal_read_repair_chance=0.000000 AND
>>>   gc_grace_seconds=864000 AND
>>>   read_repair_chance=0.100000 AND
>>>   replicate_on_write='true' AND
>>>   populate_io_cache_on_flush='false' AND
>>>   compaction={'class': 'SizeTieredCompactionStrategy'} AND
>>>   compression={'sstable_compression': 'SnappyCompressor'};
>>>
>>> cqlsh:cql3usage> select * from user;
>>>
>>>  user_id
>>> ---------
>>>  @mevivs
>>>
>>>
>>>
>>>
>>>
>>> I understand that, CQL3 and thrift interoperability is an issue. But
>>> this looks to me a very basic scenario.
>>>
>>>
>>>
>>> Any suggestions? Or If anybody can explain a reason behind this?
>>>
>>> -Vivek
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
>
> --
> Jonathan Ellis
> Project Chair, Apache Cassandra
> co-founder, http://www.datastax.com
> @spyced
>

Reply via email to