private String getCreateWorkflowsTableStatement() { return SchemaBuilder.createTable(config.getCassandraKeyspace(), TABLE_WORKFLOWS) .ifNotExists() .addPartitionKey(WORKFLOW_ID_KEY, DataType.uuid()) .addPartitionKey(SHARD_ID_KEY, DataType.cint()) .addClusteringColumn(ENTITY_KEY, DataType.text()) .addClusteringColumn(TASK_ID_KEY, DataType.text()) .addColumn(PAYLOAD_KEY, DataType.text()) .addStaticColumn(TOTAL_TASKS_KEY, DataType.cint()) .addStaticColumn(TOTAL_PARTITIONS_KEY, DataType.cint()) .getQueryString(); }
@Test( groups = "unit", expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "The table 'test' cannot declare static columns '\\[stat\\]' without clustering columns") public void should_fail_if_static_column_in_non_clustered_table() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addStaticColumn("stat", DataType.text()) .getQueryString(); }
@Test( groups = "unit", expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "The '\\[pk\\]' columns can not be declared as partition keys and static columns at the same time") public void should_fail_if_same_partition_and_static_column() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addStaticColumn("pk", DataType.text()) .getQueryString(); }
@Test( groups = "unit", expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "The '\\[cluster\\]' columns can not be declared as clustering keys and static columns at the same time") public void should_fail_if_same_clustering_and_static_column() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addClusteringColumn("cluster", DataType.bigint()) .addStaticColumn("cluster", DataType.text()) .getQueryString(); }
@Test(groups = "unit") public void should_create_table_with_static_column() throws Exception { // When SchemaStatement statement = createTable("test") .addPartitionKey("id", DataType.bigint()) .addClusteringColumn("col", DataType.uuid()) .addStaticColumn("bucket", DataType.cint()) .addColumn("name", DataType.text()); // Then assertThat(statement.getQueryString()) .isEqualTo( "\n\tCREATE TABLE test(\n\t\t" + "id bigint,\n\t\t" + "col uuid,\n\t\t" + "bucket int static,\n\t\t" + "name text,\n\t\t" + "PRIMARY KEY(id, col))"); }
@Test( groups = "unit", expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "The '\\[col\\]' columns can not be declared as simple columns and static columns at the same time") public void should_fail_if_same_simple_and_static_column() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addClusteringColumn("cluster", DataType.uuid()) .addColumn("col", DataType.bigint()) .addStaticColumn("col", DataType.text()) .getQueryString(); }
@Test( groups = "unit", expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The static column name 'ADD' is not allowed because it is a reserved keyword") public void should_fail_if_static_column_is_a_reserved_keyword() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addClusteringColumn("cluster", DataType.uuid()) .addStaticColumn("ADD", DataType.text()) .addColumn("col", DataType.text()) .getQueryString(); }
@Test( groups = "unit", expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "Cannot create table 'test' with compact storage and static columns '\\[stat\\]'") public void should_fail_creating_table_with_static_columns_and_compact_storage() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addClusteringColumn("cluster", DataType.uuid()) .addStaticColumn("stat", DataType.text()) .withOptions() .compactStorage() .getQueryString(); } }
.addUDTClusteringColumn("d", myUDT) .addUDTColumn("e", myUDT) .addStaticColumn("f", DataType.bigint()) .addUDTStaticColumn("g", myUDT) .addUDTListColumn("h", myUDT)
@Test( groups = "unit", expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "The table 'test' cannot declare static columns '\\[stat\\]' without clustering columns") public void should_fail_if_static_column_in_non_clustered_table() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addStaticColumn("stat", DataType.text()) .getQueryString(); }
@Test( groups = "unit", expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "The '\\[pk\\]' columns can not be declared as partition keys and static columns at the same time") public void should_fail_if_same_partition_and_static_column() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addStaticColumn("pk", DataType.text()) .getQueryString(); }
@Test( groups = "unit", expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "The '\\[cluster\\]' columns can not be declared as clustering keys and static columns at the same time") public void should_fail_if_same_clustering_and_static_column() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addClusteringColumn("cluster", DataType.bigint()) .addStaticColumn("cluster", DataType.text()) .getQueryString(); }
@Test(groups = "unit") public void should_create_table_with_static_column() throws Exception { // When SchemaStatement statement = createTable("test") .addPartitionKey("id", DataType.bigint()) .addClusteringColumn("col", DataType.uuid()) .addStaticColumn("bucket", DataType.cint()) .addColumn("name", DataType.text()); // Then assertThat(statement.getQueryString()) .isEqualTo( "\n\tCREATE TABLE test(\n\t\t" + "id bigint,\n\t\t" + "col uuid,\n\t\t" + "bucket int static,\n\t\t" + "name text,\n\t\t" + "PRIMARY KEY(id, col))"); }
@Test( groups = "unit", expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The static column name 'ADD' is not allowed because it is a reserved keyword") public void should_fail_if_static_column_is_a_reserved_keyword() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addClusteringColumn("cluster", DataType.uuid()) .addStaticColumn("ADD", DataType.text()) .addColumn("col", DataType.text()) .getQueryString(); }
@Test( groups = "unit", expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "The '\\[col\\]' columns can not be declared as simple columns and static columns at the same time") public void should_fail_if_same_simple_and_static_column() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addClusteringColumn("cluster", DataType.uuid()) .addColumn("col", DataType.bigint()) .addStaticColumn("col", DataType.text()) .getQueryString(); }
@Test( groups = "unit", expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "Cannot create table 'test' with compact storage and static columns '\\[stat\\]'") public void should_fail_creating_table_with_static_columns_and_compact_storage() throws Exception { createTable("test") .addPartitionKey("pk", DataType.bigint()) .addClusteringColumn("cluster", DataType.uuid()) .addStaticColumn("stat", DataType.text()) .withOptions() .compactStorage() .getQueryString(); } }