{"record":{"id":"a0124d0b004dabbd","repo":"apache/cassandra","slug":"provided-dictionary-can-not-be-consumed-by-table-s","errorCode":null,"errorMessage":"Provided dictionary can not be consumed by table's compressor. Provided dictionary type: ; expected dictionary type by the compressor: ","messagePattern":"Provided dictionary can not be consumed by table's compressor\\. Provided dictionary type: ; expected dictionary type by the compressor: ","errorType":"validation","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java","lineNumber":769,"sourceCode":"                    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,\n                                                                    tableName,\n                                                                    tableMetadata,\n                                                                    directories,\n                                                                    false,\n                                                                    false);\n","sourceCodeStart":751,"sourceCodeEnd":787,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java#L751-L787","documentation":"When a compression dictionary is provided to CQLSSTableWriter, build() additionally checks that the dictionary's kind matches the kind the table's IDictionaryCompressor can consume (e.g. a training vs. serialization dictionary, or zstd vs. another algorithm). A mismatch means the compressor would produce unreadable or invalid SSTables, so an IllegalStateException names both the provided dictionary kind and the expected kind.","triggerScenarios":"Calling CQLSSTableWriter.builder() with a dictionary whose IDictionary.kind() differs from compressor.acceptableDictionaryKind() — e.g. passing a zstd training dictionary where a serialization/compression dictionary is required, or a dictionary built for a different compressor class.","commonSituations":"Reusing dictionaries generated for one compression algorithm/table with another; training a new dictionary but passing the trainer artifact instead of the serialized dictionary; cross-version dictionary files.","solutions":["Regenerate or convert the dictionary so its kind matches compressor.acceptableDictionaryKind() as reported in the message","Verify you are passing the final serialization dictionary, not the training corpus artifact","Ensure the table's compressor class matches the algorithm the dictionary was created for (e.g. zstd dictionary with ZstdCompressor)"],"exampleFix":"// before\nwriter = CQLSSTableWriter.builder()\n    .withCompressionDictionary(trainingDictionary) // wrong kind\n    .build();\n// after\nwriter = CQLSSTableWriter.builder()\n    .withCompressionDictionary(serializedZstdDictionary) // matches compressor.acceptableDictionaryKind()\n    .build();","handlingStrategy":"validation","validationCode":"if (dict.kind() != ((IDictionaryCompressor) params.getSstableCompressor()).acceptableDictionaryKind())\n    throw new IllegalArgumentException(\"Dictionary kind \" + dict.kind() + \" != expected \" + ((IDictionaryCompressor) params.getSstableCompressor()).acceptableDictionaryKind());","typeGuard":"boolean kindsMatch = dict.kind() == ((IDictionaryCompressor) compressionParams.getSstableCompressor()).acceptableDictionaryKind();","tryCatchPattern":"try { writer = builder.build(); }\ncatch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Provided dictionary can not be consumed\"))\n        // regenerate dictionary with the kind named in the message\n}","preventionTips":["Store dictionaries alongside the compressor class they were trained for","Use the same dictionary-management pipeline for training and loading","Validate dictionary kind against acceptableDictionaryKind() before build()"],"tags":["sstable","compression","dictionary","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}