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
signature.asc
Description: PGP signature
