You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Aleksey Yeschenko (JIRA)" <ji...@apache.org> on 2015/02/10 23:59:12 UTC

[jira] [Resolved] (CASSANDRA-8339) Reading columns marked as type different than default validation class from CQL causes errors

     [ https://issues.apache.org/jira/browse/CASSANDRA-8339?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aleksey Yeschenko resolved CASSANDRA-8339.
------------------------------------------
    Resolution: Duplicate

Closing as duplicate of CASSANDRA-8099, whether or not the initial version will handle this issue. Because nothing else will.

> Reading columns marked as type different than default validation class from CQL causes errors
> ---------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-8339
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-8339
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Erik Forsberg
>            Assignee: Aleksey Yeschenko
>
> As [discussed on users mailing list|http://www.mail-archive.com/user%40cassandra.apache.org/msg39251.html] I'm having trouble reading data from a table created via thrift, where some columns are marked as having a validator different than the default one.
> Minimal working example:
> {noformat}
> #!/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':'test@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()
>     
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)