diff --git a/src/java/org/apache/cassandra/schema/CompressionParams.java b/src/java/org/apache/cassandra/schema/CompressionParams.java index 9b1fcb62340f..272a7374f7ff 100644 --- a/src/java/org/apache/cassandra/schema/CompressionParams.java +++ b/src/java/org/apache/cassandra/schema/CompressionParams.java @@ -87,8 +87,6 @@ public final class CompressionParams public static final CompressionParams DEFAULT = DatabaseDescriptor.shouldUseAdaptiveCompressionByDefault() ? ADAPTIVE : FAST; - public static final CompressionParams INDEX_DEFAULT = DEFAULT.withChunkLength(DEFAULT_INDEX_CHUNK_LENGTH); - public static final CompressionParams NOOP = new CompressionParams(NoopCompressor.create(Collections.emptyMap()), // 4 KiB is often the underlying disk block size 1024 * 4, diff --git a/src/java/org/apache/cassandra/schema/IndexMetadata.java b/src/java/org/apache/cassandra/schema/IndexMetadata.java index 2a7a4d7e01cb..bae4b6060307 100644 --- a/src/java/org/apache/cassandra/schema/IndexMetadata.java +++ b/src/java/org/apache/cassandra/schema/IndexMetadata.java @@ -308,10 +308,22 @@ public void appendCqlTo(CqlBuilder builder, TableMetadata table, boolean ifNotEx .append(") USING ") .appendWithSingleQuotes(copyOptions.remove(IndexTarget.CUSTOM_INDEX_OPTION_NAME)); - builder.append(" WITH compression = ") - .append(compression.asMap()) - .append(" AND options = ") - .append(copyOptions); + if (compression.isEnabled()) + { + builder.append(" WITH compression = ") + .append(compression.asMap()); + + if (!copyOptions.isEmpty()) + { + builder.append(" AND options = ") + .append(copyOptions); + } + } + else if (!copyOptions.isEmpty()) + { + builder.append(" WITH options = ") + .append(copyOptions); + } } else { diff --git a/src/java/org/apache/cassandra/schema/TableParams.java b/src/java/org/apache/cassandra/schema/TableParams.java index 8e2e9bed2620..50662e25cbb9 100644 --- a/src/java/org/apache/cassandra/schema/TableParams.java +++ b/src/java/org/apache/cassandra/schema/TableParams.java @@ -289,13 +289,12 @@ public void appendCqlTo(CqlBuilder builder, boolean isView) .newLine() .append("AND compression = ").append(compression.asMap()) .newLine() - .append("AND index_compression = ").append(indexCompression.asMap()) - .newLine() .append("AND memtable = ").append(memtable.asMap()) .newLine() .append("AND crc_check_chance = ").append(crcCheckChance) .newLine(); + if (!isView) { builder.append("AND default_time_to_live = ").append(defaultTimeToLive) @@ -309,8 +308,16 @@ public void appendCqlTo(CqlBuilder builder, boolean isView) false) .newLine() .append("AND gc_grace_seconds = ").append(gcGraceSeconds) - .newLine() - .append("AND max_index_interval = ").append(maxIndexInterval) + .newLine(); + + + if (indexCompression.isEnabled()) + { + builder.append("AND index_compression = ").append(indexCompression.asMap()) + .newLine(); + } + + builder.append("AND max_index_interval = ").append(maxIndexInterval) .newLine() .append("AND memtable_flush_period_in_ms = ").append(memtableFlushPeriodInMs) .newLine() @@ -336,7 +343,7 @@ public static final class Builder private CachingParams caching = CachingParams.DEFAULT; private CompactionParams compaction = CompactionParams.DEFAULT; private CompressionParams compression = CompressionParams.DEFAULT; - private CompressionParams indexCompression = CompressionParams.INDEX_DEFAULT; + private CompressionParams indexCompression = CompressionParams.noCompression(); private MemtableParams memtable = MemtableParams.DEFAULT; private ImmutableMap extensions = ImmutableMap.of(); private boolean cdc; diff --git a/test/unit/org/apache/cassandra/cql3/statements/DescribeStatementTest.java b/test/unit/org/apache/cassandra/cql3/statements/DescribeStatementTest.java index f8cf224dbd87..dc9f66b6bc85 100644 --- a/test/unit/org/apache/cassandra/cql3/statements/DescribeStatementTest.java +++ b/test/unit/org/apache/cassandra/cql3/statements/DescribeStatementTest.java @@ -809,7 +809,7 @@ public void testDescribeWithCustomIndex() throws Throwable { String table = createTable(KEYSPACE_PER_TEST, "CREATE TABLE %s (id int PRIMARY KEY, value text);"); String indexWithoutOptions = createIndex(KEYSPACE_PER_TEST, "CREATE CUSTOM INDEX ON %s(value) USING 'org.apache.cassandra.index.sasi.SASIIndex';"); - String indexWithOptions = createIndex(KEYSPACE_PER_TEST, "CREATE CUSTOM INDEX ON %s(value) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'is_literal': 'false'};"); + String indexWithOptions = createIndex(KEYSPACE_PER_TEST, "CREATE CUSTOM INDEX ON %s(value) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH options = {'is_literal': 'false'};"); String expectedKeyspaceStmt = "CREATE KEYSPACE " + KEYSPACE_PER_TEST + " WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}" + @@ -821,7 +821,7 @@ public void testDescribeWithCustomIndex() throws Throwable ") WITH " + tableParametersCql(); String expectedIndexStmtWithoutOptions = "CREATE CUSTOM INDEX " + indexWithoutOptions + " ON " + KEYSPACE_PER_TEST + "." + table + " (value) USING 'org.apache.cassandra.index.sasi.SASIIndex';"; - String expectedIndexStmtWithOptions = "CREATE CUSTOM INDEX " + indexWithOptions + " ON " + KEYSPACE_PER_TEST + "." + table + " (value) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'is_literal': 'false'};"; + String expectedIndexStmtWithOptions = "CREATE CUSTOM INDEX " + indexWithOptions + " ON " + KEYSPACE_PER_TEST + "." + table + " (value) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH options = {'is_literal': 'false'};"; assertRowsNet(executeDescribeNet("DESCRIBE KEYSPACE " + KEYSPACE_PER_TEST), row(KEYSPACE_PER_TEST, "keyspace", KEYSPACE_PER_TEST, expectedKeyspaceStmt),