cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aleksey Yeschenko (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-8339) Reading columns marked as type different than default validation class from CQL causes errors
Date Tue, 10 Feb 2015 22:58:12 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-8339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14315127#comment-14315127
] 

Aleksey Yeschenko commented on CASSANDRA-8339:
----------------------------------------------

Let me also note that the output of DESCRIBE here is a lie. It should either be:

{noformat}
CREATE TABLE "Users" (
  key 'org.apache.cassandra.db.marshal.LexicalUUIDType',
  column1 ascii,
  value text,
  PRIMARY KEY ((key), column1)
) WITH COMPACT STORAGE;
{noformat}

or

{noformat}
CREATE TABLE "Users" (
  key 'org.apache.cassandra.db.marshal.LexicalUUIDType',
  active varint,
  date_created bigint,
  default_account_id 'org.apache.cassandra.db.marshal.LexicalUUIDType',
  email text,
  username text,
  PRIMARY KEY ((key))
) WITH COMPACT STORAGE;
{noformat}

The first version is how CQL3 actually sees the table.

> 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)

Mime
View raw message