def get_table(keyspace, name): table = TableMetadata(keyspace.name, name) # build columns for each data type columns_dict = {} for i in range(len(data_types)): col = column(table, "my_column_%s" % i, data_types[i]) columns_dict[col.name] = col # create some udts address_udt = udt(keyspace, "address", ["street", "number"], ["text", "int"]) user_udt = udt(keyspace, "user", ["name", "address"], ["tuple<text,text>", "frozen<address>"]) collections_udt = udt(keyspace, "collections", ["field1", "field2", "field3", "field4"], ["frozen<user>",\ "frozen<map<frozen<user>, frozen<user>>>",\ "frozen<list<frozen<address>>>",\ "frozen<tuple<frozen<user>, frozen<address>>>"]) # add udts to keyspace keyspace.user_types = {address_udt.name: address_udt,\ user_udt.name: user_udt,\ collections_udt.name: collections_udt} # build column with udt types columns_dict["user"] = column(table, user_udt.name, "frozen<%s>" % user_udt.name) columns_dict["collections"] = column(table, collections_udt.name, "frozen<%s>" % collections_udt.name) # set some pk's and ck's columns = list(columns_dict.values()) partition_keys = [columns[0], columns[1]] clustering_keys = [columns[2], columns[3]] table.columns = columns_dict table.partition_key = partition_keys table.clustering_key = clustering_keys # indexes indexes = {} # add a regular index regular_index = index(keyspace, name, "regular_index_" + name, None, {"target": "my_column_0"}) indexes[regular_index.name] = regular_index # add a CUSTOM index (this must be removed by the anonymizer) custom_index = index( keyspace, name, "custom_index_" + name, "CUSTOM", { "target": "my_column_5", "class_name": "org.apache.cassandra.index.sasi.SASIIndex" }) indexes[custom_index.name] = custom_index table.indexes = indexes # table options compatible with C* 2.1+ table.options = { # set a comment, which must be removed by the anonymizer "comment": "Lorem ipsum", "compaction_strategy_class": "org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy", "max_compaction_threshold": "32", "min_compaction_threshold": "4", "compression_parameters": '{"sstable_compression": ""}' } return table