Skip to content

Instantly share code, notes, and snippets.

@aholmberg
Created August 3, 2016 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aholmberg/d482d78e1544148523b78c375e636bc7 to your computer and use it in GitHub Desktop.
Save aholmberg/d482d78e1544148523b78c375e636bc7 to your computer and use it in GitHub Desktop.
------------------------------------------------------------------------------------------------------
CREATE COLUMN FAMILY simple_no_col
WITH comparator = UTF8Type
AND key_validation_class = UUIDType
AND default_validation_class = UTF8Type;
CREATE TABLE legacy.simple_no_col (
key uuid,
column1 text,
value text,
PRIMARY KEY (key, column1)
) WITH COMPACT STORAGE
AND CLUSTERING ORDER BY (column1 ASC)
...;
------------------------------------------------------------------------------------------------------
CREATE COLUMN FAMILY simple_with_col
WITH comparator = UTF8Type
and key_validation_class = UUIDType
and default_validation_class = UTF8Type
AND column_metadata = [
{column_name: col_with_meta, validation_class: UTF8Type}
];
CREATE TABLE legacy.simple_with_col (
key uuid PRIMARY KEY,
col_with_meta text
) WITH COMPACT STORAGE
...;
------------------------------------------------------------------------------------------------------
CREATE COLUMN FAMILY composite_partition_no_col
WITH comparator = UTF8Type
AND key_validation_class = 'CompositeType(UUIDType,UTF8Type)'
AND default_validation_class = UTF8Type;
CREATE TABLE legacy.composite_partition_no_col (
key uuid,
key2 text,
column1 text,
value text,
PRIMARY KEY ((key, key2), column1)
) WITH COMPACT STORAGE
AND CLUSTERING ORDER BY (column1 ASC)
...;
------------------------------------------------------------------------------------------------------
CREATE COLUMN FAMILY composite_partition_with_col
WITH comparator = UTF8Type
AND key_validation_class = 'CompositeType(UUIDType,UTF8Type)'
AND default_validation_class = UTF8Type
AND column_metadata = [
{column_name: col_with_meta, validation_class: UTF8Type}
];
CREATE TABLE legacy.composite_partition_with_col (
key uuid,
key2 text,
col_with_meta text,
PRIMARY KEY ((key, key2))
) WITH COMPACT STORAGE
...;
------------------------------------------------------------------------------------------------------
CREATE COLUMN FAMILY nested_composite_key
WITH comparator = UTF8Type
and key_validation_class = 'CompositeType(CompositeType(UUIDType,UTF8Type), LongType)'
and default_validation_class = UTF8Type
AND column_metadata = [
{column_name: full_name, validation_class: UTF8Type}
];
CREATE TABLE legacy.nested_composite_key (
key 'org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UUIDType,org.apache.cassandra.db.marshal.UTF8Type)',
key2 bigint,
full_name text,
PRIMARY KEY ((key, key2))
) WITH COMPACT STORAGE
...;
------------------------------------------------------------------------------------------------------
create column family composite_comp_no_col
with column_type = 'Standard'
and comparator = 'DynamicCompositeType(t=>org.apache.cassandra.db.marshal.TimeUUIDType,s=>org.apache.cassandra.db.marshal.UTF8Type,b=>org.apache.cassandra.db.marshal.BytesType)'
and default_validation_class = 'BytesType'
and key_validation_class = 'BytesType';
CREATE TABLE legacy.composite_comp_no_col (
key blob,
column1 'org.apache.cassandra.db.marshal.DynamicCompositeType(b=>org.apache.cassandra.db.marshal.BytesType,s=>org.apache.cassandra.db.marshal.UTF8Type,t=>org.apache.cassandra.db.marshal.TimeUUIDType)',
value blob,
PRIMARY KEY (key, column1)
) WITH COMPACT STORAGE
AND CLUSTERING ORDER BY (column1 ASC)
...;
------------------------------------------------------------------------------------------------------
create column family composite_comp_with_col
with column_type = 'Standard'
and comparator = 'DynamicCompositeType(t=>org.apache.cassandra.db.marshal.TimeUUIDType,s=>org.apache.cassandra.db.marshal.UTF8Type,b=>org.apache.cassandra.db.marshal.BytesType)'
and default_validation_class = 'BytesType'
and key_validation_class = 'BytesType'
and column_metadata = [
{column_name : 'b@6d616d6d616a616d6d61',
validation_class : BytesType,
index_name : 'idx_one',
index_type : 0},
{column_name : 'b@6869746d65776974686d75736963',
validation_class : BytesType,
index_name : 'idx_two',
index_type : 0}];
/*
Warning: Table legacy.composite_comp_with_col omitted because it has constructs not compatible with CQL (was created via legacy API).
Approximate structure, for reference:
(this should not be used to reproduce this schema)
CREATE TABLE legacy.composite_comp_with_col (
key blob,
column1 'org.apache.cassandra.db.marshal.DynamicCompositeType(b=>org.apache.cassandra.db.marshal.BytesType,s=>org.apache.cassandra.db.marshal.UTF8Type,t=>org.apache.cassandra.db.marshal.TimeUUIDType)',
"b@6869746d65776974686d75736963" blob static,
"b@6d616d6d616a616d6d61" blob static,
PRIMARY KEY (key, column1)
) WITH COMPACT STORAGE
AND CLUSTERING ORDER BY (column1 ASC)
...;
CREATE INDEX idx_two ON legacy.composite_comp_with_col ("b@6869746d65776974686d75736963");
CREATE INDEX idx_one ON legacy.composite_comp_with_col ("b@6d616d6d616a616d6d61");
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment