On 2014-11-17 09:56, Erik Forsberg wrote: > On 2014-11-15 01:24, Tyler Hobbs wrote: >> What version of cassandra did you originally create the column family >> in? Have you made any schema changes to it through cql or >> cassandra-cli, or has it always been exactly the same? > > Oh that's a tough question given that the cluster has been around since > 2011. So CF was probably created in Cassandra 0.7 or 0.8 via thrift > calls from pycassa, and I don't think there has been any schema changes > to it since.
Actually, I don't think it matters. I created a minimal repeatable set of python code (see below). Running that against a 2.0.11 server, creating fresh keyspace and CF, then insert some data with thrift/pycassa, then trying to extract the data that has a different validation class, the python-driver and cqlsh bails out. cqlsh example after running the below script: cqlsh:badcql> select * from "Users" where column1 = 'default_account_id' ALLOW FILTERING; value "\xf9\x8bu}!\xe9C\xbb\xa7=\xd0\x8a\xff';\xe5" (in col 'value') can't be deserialized as text: 'utf8' codec can't decode byte 0xf9 in position 0: invalid start byte cqlsh:badcql> select * from "Users" where column1 = 'date_created' ALLOW FILTERING; value '\x00\x00\x00\x00Ti\xe0\xbe' (in col 'value') can't be deserialized as text: 'utf8' codec can't decode bytes in position 6-7: unexpected end of data So the question remains - how do I work with this data from cqlsh and / or the python driver? Thanks, \EF --repeatable example-- #!/usr/bin/env python # Run this in virtualenv with pycassa and cassandra-driver installed via pip import pycassa import cassandra import calendar import traceback import time from uuid import uuid4 keyspace = "badcql" sysmanager = pycassa.system_manager.SystemManager("localhost") sysmanager.create_keyspace(keyspace, strategy_options={'replication_factor':'1'}) sysmanager.create_column_family(keyspace, "Users", key_validation_class=pycassa.system_manager.LEXICAL_UUID_TYPE, comparator_type=pycassa.system_manager.ASCII_TYPE, default_validation_class=pycassa.system_manager.UTF8_TYPE) sysmanager.create_index(keyspace, "Users", "username", pycassa.system_manager.UTF8_TYPE) sysmanager.create_index(keyspace, "Users", "email", pycassa.system_manager.UTF8_TYPE) sysmanager.alter_column(keyspace, "Users", "default_account_id", pycassa.system_manager.LEXICAL_UUID_TYPE) sysmanager.create_index(keyspace, "Users", "active", pycassa.system_manager.INT_TYPE) sysmanager.alter_column(keyspace, "Users", "date_created", pycassa.system_manager.LONG_TYPE) pool = pycassa.pool.ConnectionPool(keyspace, ['localhost:9160']) cf = pycassa.ColumnFamily(pool, "Users") user_uuid = uuid4() cf.insert(user_uuid, {'username':'test_username', 'auth_method':'ldap', 'email':'t...@example.com', 'active':1, 'date_created':long(calendar.timegm(time.gmtime())), 'default_account_id':uuid4()}) from cassandra.cluster import Cluster cassandra_cluster = Cluster(["localhost"]) cassandra_session = cassandra_cluster.connect(keyspace) print "username", cassandra_session.execute('SELECT value from "Users" where key = %s and column1 = %s', (user_uuid, 'username',)) print "email", cassandra_session.execute('SELECT value from "Users" where key = %s and column1 = %s', (user_uuid, 'email',)) try: print "default_account_id", cassandra_session.execute('SELECT value from "Users" where key = %s and column1 = %s', (user_uuid, 'default_account_id',)) except Exception as e: print "Exception trying to get default_account_id", traceback.format_exc() cassandra_session = cassandra_cluster.connect(keyspace) try: print "active", cassandra_session.execute('SELECT value from "Users" where key = %s and column1 = %s', (user_uuid, 'active',)) except Exception as e: print "Exception trying to get active", traceback.format_exc() cassandra_session = cassandra_cluster.connect(keyspace) try: print "date_created", cassandra_session.execute('SELECT value from "Users" where key = %s and column1 = %s', (user_uuid, 'date_created',)) except Exception as e: print "Exception trying to get date_created", traceback.format_exc() -- end of example --