{"record":{"id":"989ab758a7bc78e7","repo":"apache/cassandra","slug":"table-s-compressor-can-not-accept-any-dictionary","errorCode":null,"errorMessage":"Table's compressor can not accept any dictionary: ","messagePattern":"Table's compressor can not accept any dictionary: ","errorType":"validation","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java","lineNumber":763,"sourceCode":"                    {\n                        // we need to commit keyspace metadata first so applyIndexes sees that keyspace from TCM\n                        commitKeyspaceMetadata(ksm.withSwapped(ksm.tables.with(tableMetadata)));\n                        applyIndexes(keyspaceName);\n                    }\n\n                    KeyspaceMetadata keyspaceMetadata = ClusterMetadata.current().schema.getKeyspaceMetadata(keyspaceName);\n                    tableMetadata = keyspaceMetadata.tables.getNullable(tableName);\n\n                    Schema.instance.submit(SchemaTransformations.addTable(tableMetadata, true));\n                }\n\n                if (compressionDictionary != null)\n                {\n                    CompressionParams compressionParams = tableMetadata.params.compression;\n\n                    if (!compressionParams.isDictionaryCompressionEnabled())\n                    {\n                        throw new IllegalStateException(\"Table's compressor can not accept any dictionary: \" + compressionParams.asMap());\n                    }\n\n                    IDictionaryCompressor compressor = (IDictionaryCompressor) compressionParams.getSstableCompressor();\n                    if (!compressor.canConsumeDictionary(compressionDictionary))\n                    {\n                        throw new IllegalStateException(\"Provided dictionary can not be consumed by table's compressor. \" +\n                                                        \"Provided dictionary type: \" + compressionDictionary.kind() +\n                                                        \"; expected dictionary type by the compressor: \" + compressor.acceptableDictionaryKind());\n                    }\n                }\n\n                ColumnFamilyStore cfs = null;\n                if ((buildIndexes && !indexStatements.isEmpty()) || compressionDictionary != null)\n                {\n                    KeyspaceMetadata keyspaceMetadata = ClusterMetadata.current().schema.getKeyspaceMetadata(keyspaceName);\n                    Keyspace keyspace = Keyspace.mockKS(keyspaceMetadata);\n                    Directories directories = new Directories(tableMetadata, Collections.singleton(new Directories.DataDirectory(new File(directory.toPath()))));\n                    cfs = ColumnFamilyStore.createColumnFamilyStore(keyspace,","sourceCodeStart":745,"sourceCodeEnd":781,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java#L745-L781","documentation":"CQLSSTableWriter.build() validates that, when a compression dictionary was supplied to the writer, the table's compression params actually enable dictionary-based compression. If the compressor is not dictionary-enabled, Cassandra cannot attach the dictionary to the SSTables it writes, so it fails fast with an IllegalStateException containing the compression params map. This prevents silently writing SSTables without the requested dictionary.","triggerScenarios":"Calling CQLSSTableWriter.builder() with .withCompressionDictionary(...) (or an equivalent option) while the table schema's CompressionParams do not have dictionary compression enabled (e.g. using a plain compressor like LZ4/Snappy/Deflate instead of a dictionary compressor such as Zstd with dictionary support).","commonSituations":"Scripts that bulk-load SSTables with offline compression dictionaries against tables whose CREATE TABLE compression options were copied from a non-dictionary template; upgrading schemas where compression options were reverted; mixing writer options from one cluster's schema with another table's.","solutions":["Enable dictionary compression on the table, e.g. CREATE/ALTER the table with compression {'class': 'ZstdCompressor', 'zstd_dictionary': ...} or the dictionary-enabled compression option before building the writer","Remove the compressionDictionary option from the CQLSSTableWriter builder so validation passes for a non-dictionary compressor","Inspect compressionParams.asMap() in the message to confirm which compression class is configured and switch to IDictionaryCompressor-based settings"],"exampleFix":"// before\nCQLSSTableWriter writer = CQLSSTableWriter.builder()\n    .inTable(table)\n    .withCompressionDictionary(dict)\n    .forTable(\"CREATE TABLE ks.t (...) WITH compression = {'class': 'LZ4Compressor'};\")\n    .build();\n// after\nCQLSSTableWriter writer = CQLSSTableWriter.builder()\n    .inTable(table)\n    .withCompressionDictionary(dict)\n    .forTable(\"CREATE TABLE ks.t (...) WITH compression = {'class': 'ZstdCompressor', 'compression_dictionary': '...'};\")\n    .build();","handlingStrategy":"validation","validationCode":"CompressionParams cp = tableMetadata.params.compression;\nif (dict != null && !(cp.getSstableCompressor() instanceof IDictionaryCompressor))\n    throw new IllegalStateException(\"Dictionary given but compressor is not dictionary-capable: \" + cp.asMap());","typeGuard":"boolean canUseDict = dict != null\n    && tableMetadata.params.compression.isDictionaryCompressionEnabled()\n    && tableMetadata.params.compression.getSstableCompressor() instanceof IDictionaryCompressor;","tryCatchPattern":"try (CQLSSTableWriter w = builder.build()) { ... }\ncatch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Table's compressor can not accept any dictionary\"))\n        // fix schema compression options or drop the dictionary option\n}\n","preventionTips":["Verify the table's compression class supports dictionaries before passing a dictionary","Keep table DDL and writer dictionary options in sync in load scripts","Log compressionParams.asMap() during load-script setup"],"tags":["sstable","compression","illegal-state","bulk-loading"],"backgroundTag":"invalid-config-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}