@Test(groups = "unit") public void should_create_table_with_clustering_order() throws Exception { // When SchemaStatement statement = createTable("test") .addPartitionKey("id", DataType.bigint()) .addClusteringColumn("col1", DataType.uuid()) .addClusteringColumn("col2", DataType.uuid()) .addColumn("name", DataType.text()) .withOptions() .clusteringOrder("col1", Direction.ASC) .clusteringOrder("col2", Direction.DESC); // Then assertThat(statement.getQueryString()) .isEqualTo( "\n\tCREATE TABLE test(\n\t\t" + "id bigint,\n\t\t" + "col1 uuid,\n\t\t" + "col2 uuid,\n\t\t" + "name text,\n\t\t" + "PRIMARY KEY(id, col1, col2))\n\t" + "WITH CLUSTERING ORDER BY(col1 ASC, col2 DESC)"); }
@Test(groups = "unit", expectedExceptions = IllegalArgumentException.class) public void should_fail_when_clustering_order_column_does_not_match_declared_clustering_keys() throws Exception { createTable("test") .addPartitionKey("id", DataType.bigint()) .addClusteringColumn("col1", DataType.uuid()) .addClusteringColumn("col2", DataType.uuid()) .addColumn("name", DataType.text()) .withOptions() .clusteringOrder("col3", Direction.ASC); }
@Test(groups = "unit", expectedExceptions = IllegalArgumentException.class) public void should_fail_when_blank_clustering_order_column_provided() throws Exception { createTable("test") .addPartitionKey("id", DataType.bigint()) .addClusteringColumn("col1", DataType.uuid()) .addClusteringColumn("col2", DataType.uuid()) .addColumn("name", DataType.text()) .withOptions() .clusteringOrder("", Direction.DESC); }
.addColumn("name", DataType.text()) .withOptions() .clusteringOrder("col1", Direction.ASC) .clusteringOrder("col2", Direction.DESC) .compactStorage() .bloomFilterFPChance(0.01)
.withOptions() .clusteringOrder(PLACEMENT_COLUMN, SchemaBuilder.Direction.ASC) .clusteringOrder(RANGE_TOKEN_COLUMN, SchemaBuilder.Direction.ASC) .clusteringOrder(IS_START_TOKEN_COLUMN, SchemaBuilder.Direction.ASC) .compactStorage() .defaultTimeToLive(TTL));
.withOptions() .clusteringOrder(PLACEMENT_COLUMN, SchemaBuilder.Direction.ASC) .clusteringOrder(RANGE_TOKEN_COLUMN, SchemaBuilder.Direction.ASC) .clusteringOrder(IS_START_TOKEN_COLUMN, SchemaBuilder.Direction.ASC) .compactStorage() .defaultTimeToLive(TTL));
.populateIOCacheOnFlush(tableMetadata.getCachePriority() == CachePriority.HOTTEST) .speculativeRetry(SchemaBuilder.noSpeculativeRetry()) .clusteringOrder(COLUMN, SchemaBuilder.Direction.ASC) .clusteringOrder(TIMESTAMP, SchemaBuilder.Direction.ASC) .buildInternal();
@Test(groups = "unit") public void should_create_table_with_clustering_order() throws Exception { // When SchemaStatement statement = createTable("test") .addPartitionKey("id", DataType.bigint()) .addClusteringColumn("col1", DataType.uuid()) .addClusteringColumn("col2", DataType.uuid()) .addColumn("name", DataType.text()) .withOptions() .clusteringOrder("col1", Direction.ASC) .clusteringOrder("col2", Direction.DESC); // Then assertThat(statement.getQueryString()) .isEqualTo( "\n\tCREATE TABLE test(\n\t\t" + "id bigint,\n\t\t" + "col1 uuid,\n\t\t" + "col2 uuid,\n\t\t" + "name text,\n\t\t" + "PRIMARY KEY(id, col1, col2))\n\t" + "WITH CLUSTERING ORDER BY(col1 ASC, col2 DESC)"); }
@Test(groups = "unit", expectedExceptions = IllegalArgumentException.class) public void should_fail_when_clustering_order_column_does_not_match_declared_clustering_keys() throws Exception { createTable("test") .addPartitionKey("id", DataType.bigint()) .addClusteringColumn("col1", DataType.uuid()) .addClusteringColumn("col2", DataType.uuid()) .addColumn("name", DataType.text()) .withOptions() .clusteringOrder("col3", Direction.ASC); }
@Test(groups = "unit", expectedExceptions = IllegalArgumentException.class) public void should_fail_when_blank_clustering_order_column_provided() throws Exception { createTable("test") .addPartitionKey("id", DataType.bigint()) .addClusteringColumn("col1", DataType.uuid()) .addClusteringColumn("col2", DataType.uuid()) .addColumn("name", DataType.text()) .withOptions() .clusteringOrder("", Direction.DESC); }
.addColumn("name", DataType.text()) .withOptions() .clusteringOrder("col1", Direction.ASC) .clusteringOrder("col2", Direction.DESC) .compactStorage() .bloomFilterFPChance(0.01)
.populateIOCacheOnFlush(tableMetadata.getCachePriority() == CachePriority.HOTTEST) .speculativeRetry(SchemaBuilder.noSpeculativeRetry()) .clusteringOrder(COLUMN, SchemaBuilder.Direction.ASC) .clusteringOrder(TIMESTAMP, SchemaBuilder.Direction.ASC) .buildInternal();