incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryce Allen <bal...@ci.uchicago.edu>
Subject Re: cli composite type literal with empty string component
Date Wed, 08 Feb 2012 16:59:37 GMT
Never mind; the issue with addressing composite column names with empty
components was fixed in the latest pycassa, which is why I was even
able to create them in the Test3 schema below. I get an error in 1.2.1
which I used to be running, but it all seems to work in 1.4.0.

-Bryce

On Wed, 8 Feb 2012 10:25:07 -0600
Bryce Allen <ballen@ci.uchicago.edu> wrote:
> I have a CF defined like this in CLI syntax:
> 
> create column family Test
>     with key_validation_class = UTF8Type
>     and comparator = 'CompositeType(AsciiType, UTF8Type)'
>     and default_validation_class = UTF8Type
>     and column_metadata = [
>         { column_name : 'deleted:',
>           validation_class : BooleanType },
>         { column_name : 'version:',
>           validation_class : LongType },
>     ];
> 
> I expected these columns to map to ("deleted", "") and ("version", "")
> in pycassa, but this is not the case:
> 
>   TEST.insert("r1", { ("deleted", ""): False, ("version", ""): 1,
>    		      ("a", "b"): "c" })
>   AttributeError: 'int' object has no attribute 'encode'
> 
>   TEST.column_validators
>   {'\x00\x07deleted\x00': 'BooleanType',
>    '\x00\x07version\x00': 'LongType'}
> 
> The obvious workaround is to use pycassa to define the schema:
> 
>   SYSTEM_MANAGER.create_column_family("test", "Test2",
>     key_validation_class=UTF8_TYPE,
>     comparator_type=CompositeType(ASCII_TYPE, UTF8_TYPE),
>     default_validation_class=UTF8_TYPE,
>     column_validation_classes={
>       ("version", ""): LONG_TYPE,
>       ("deleted", ""): BOOLEAN_TYPE })
> 
> and this does really produce a different schema:
>   
>   TEST2.column_validators
>   {'\x00\x07version\x00\x00\x00\x00': 'LongType',
>    '\x00\x07deleted\x00\x00\x00\x00': 'BooleanType'}
> 
> To mimic what CLI does, I leave off the last component instead of
> using "":
> 
>   SYSTEM_MANAGER.create_column_family("test", "Test3",
>     key_validation_class=UTF8_TYPE,
>     comparator_type=CompositeType(ASCII_TYPE, UTF8_TYPE),
>     default_validation_class=UTF8_TYPE,
>     column_validation_classes={
>       ("version",): LONG_TYPE,
>       ("deleted",): BOOLEAN_TYPE })
> 
>   TEST3.column_validators
>   {'\x00\x07deleted\x00': 'BooleanType',
>    '\x00\x07version\x00': 'LongType'}
> 
> But I see no way to address these columns from pycassa. I have a
> workaround, but I find the inconsistency perplexing, and would rather
> not have to do the busywork to convert my schema syntax. Is there a
> way to address columns with an empty string component in the CLI?
> 
> Thanks,
> Bryce

Mime
View raw message