New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JAVA-993: Support for "custom" types after CASSANDRA-10365. #533
Conversation
@@ -79,6 +79,9 @@ | |||
*/ | |||
static DataType parse(String toParse, Cluster cluster, String currentKeyspaceName, Map<String, UserType> currentUserTypes, Map<String, UserType> oldUserTypes, boolean frozen, boolean shallowUserTypes) { | |||
|
|||
if(toParse.startsWith("'")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Custom" types (i.e. types that do not have a CQL representation) appear in schema metadata in the "old" format, i.e., with cassandra internal class names, but surrounded by single quotes. If we don't do the check here, the parsed identifier will be empty.
+ " k int," | ||
+ " c1 'DynamicCompositeType(s => UTF8Type, i => Int32Type)'," | ||
+ " c2 'ReversedType(CompositeType(UTF8Type, Int32Type))'," // reversed translates to CLUSTERING ORDER BY DESC | ||
+ " c3 'ListType(Int32Type)'," // translates to list<int> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like cassandra 1.2.19 can't handle this:
ERROR [Native-Transport-Requests:78] 2015-11-19 07:26:14,539 ErrorMessage.java (line 210) Unexpected exception during request
java.lang.IllegalStateException: Composite column is already fully constructed
at org.apache.cassandra.db.marshal.CompositeType$Builder.add(CompositeType.java:300)
at org.apache.cassandra.db.marshal.CompositeType$Builder.add(CompositeType.java:332)
at org.apache.cassandra.db.marshal.CompositeType$Builder.add(CompositeType.java:269)
at org.apache.cassandra.cql3.Lists$Appender.doAppend(Lists.java:356)
at org.apache.cassandra.cql3.Lists$Setter.execute(Lists.java:271)
at org.apache.cassandra.cql3.statements.UpdateStatement.mutationForKey(UpdateStatement.java:265)
at org.apache.cassandra.cql3.statements.UpdateStatement.getMutations(UpdateStatement.java:140)
at org.apache.cassandra.cql3.statements.ModificationStatement.execute(ModificationStatement.java:118)
at org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:103)
at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:113)
at org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:87)
at org.apache.cassandra.transport.Message$Dispatcher.messageReceived(Message.java:287)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
at org.jboss.netty.handler.execution.ChannelUpstreamEventRunnable.doRun(ChannelUpstreamEventRunnable.java:43)
at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
This happens on first insert of row c3. It looks like it should work. I think it's the definition of c1 and/or c2 that is really the problem. c1 and c2 also don't appear in system.schema_columns:
cqlsh> select keyspace_name, columnfamily_name, column_name, validator from system.schema_columns where keyspace_name='ks_1';
keyspace_name | columnfamily_name | column_name | validator
---------------+-------------------+-------------+-------------------------------------------------------------------------------------
ks_1 | test | c3 | org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.Int32Type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I forgot that the primary key components are part of system.schema_columnfamilies, not columns, so that wasn't a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird error. Anyway it goes away if we change the column type to Int32Type
, so I did that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works for me 👍. It turns out the problem wasn't ListType being used with c1 and c2. It's just list type in general with 1.2. When I tested it alone I still got the same failure, it seems C* 1.2 can't figure out what to do with the custom type on the table declaration, but it works fine as 'list' (as we'd expect).
I made a change locally to use a different type for 1.2, but I think your solution is more straightforward and elegant.
Looks good to me 👍. I also added a test for UDTs with fields having custom types. |
👍 |
This commit contains contributions from Andrew Tolbert (@tolbertam).
JAVA-993: Support for "custom" types after CASSANDRA-10365.
No description provided.