Is there a programatic way to determine which UDTs a table is referring to by looking at one of the system tables? If you setup the example CQL below and look at the result of the select query you'll notice that in the 'validator' field it's not possible to really determine which UDT is being referenced for which field. There's a # after the keyspace which appears to uniquely identify the UDT actually being used but I'm not sure where to get that mapping from. I haven't been able to locate it on any system tables.
CREATE KEYSPACE IF NOT EXISTS "test"
WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
CREATE TYPE if not exists test.udt_type (
street text,
city text,
zip int
);
CREATE TYPE if not exists test.udt_type2 (
street text,
city text,
zip int
);
create table if not exists test.two_udts(
id uuid,
type1 frozen<udt_type>,
type2 frozen<udt_type2>,
type3 frozen<udt_type2>,
PRIMARY KEY(id)
);
-- shows you that there are 2 UDTs on this table but not which one is mapped to which field
select * from system.schema_columns where keyspace_name = 'test';
-- shows you the UDTs that are there
select * from system.schema_usertypes where keyspace_name = 'test';
org.apache.cassandra.db.marshal.UserType(test,7564745f74797065,737472656574:org.apache.cassandra.db.marshal.UTF8Type,63697479:org.apache.cassandra.db.marshal.UTF8Type,7a6970:org.apache.cassandra.db.marshal.Int32Type)
KeyspaceMetadata ksm = cluster.getMetadata().getKeyspace("test");
TableMetadata tm = ksm.getTable("two_udts");
UserType udtType = ksm.getUserType("udt_type");
UserType udtType2 = ksm.getUserType("udt_type2");
assert udtType == tm.getColumn("type1").getType();
assert udtType2 == tm.getColumn("type2").getType();
assert udtType2 == tm.getColumn("type3").getType();
((UserType)tm.getColumn("type3").getType()).getTypeName())
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.