Question

I'm trying to setup some column_validators in pycassa but having troubles in doing so with some kind of supercolum setup: I don't seem to be able to set a validator for a column contained in a supercolumn. I'm trying something like

cf.column_validators['supercolumn_name']['column_name'] = types.FloatType()

which doesn't work because the second dictionary isn't initialized yet, trying to set it to something like

cf.column_validators['supercolumn_name'] = {}

doesn't work either... So any example on how to handle this are appreciated, as the official pycassa doc doesn't show any more detailled information on this. Furthermore these validators don't seem to be persistent, so is there any possibility on setting them persistently?

EDIT: After looking at pycassa's source I found out, that for the validators you do not have to specify the supercolumn the column is contained in, so

cf.column_validators['column_name'] = types.FloatType()

should do the trick! Still the question remains if the validators can be made persistent somehow?

Was it helpful?

Solution

You probably don't want to be modifying column_validators directly. Those are set automatically based on the column_metadata properties of the column family. You can use the 'alter_column' command in pycassa to modify the column family schema in Cassandra. Then column_validators will be set correctly permanently.

http://pycassa.github.com/pycassa/api/pycassa/system_manager.html#pycassa.system_manager.SystemManager.alter_column

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top