apache/cassandra · error · IllegalArgumentException

It is not possible to import compression dictionaries of kin

Error message

It is not possible to import compression dictionaries of kind %s into table %s.%s which supports compression dictionaries of kind %s.

What it means

Each table supports exactly one dictionary kind (e.g. Zstd). If the imported dictionary's kind (parsed from dataObject.kind) differs from the manager's configured kind, importCompressionDictionary() throws IllegalArgumentException, since a dictionary of an incompatible algorithm cannot be used by the table's compressor.

Source

Thrown at src/java/org/apache/cassandra/db/compression/CompressionDictionaryManager.java:284

    {
        if (!isEnabled || this.kind == null)
        {
            throw new IllegalStateException(format("The compression on table %s.%s is not enabled or SSTable compressor is not a dictionary compressor.",
                                                   keyspaceName, tableName));
        }

        CompressionDictionaryDataObject dataObject = CompressionDictionaryDetailsTabularData.fromCompositeData(compositeData);

        if (!keyspaceName.equals(dataObject.keyspace) || !tableName.equals(dataObject.table))
            throw new IllegalArgumentException(format("Keyspace and table of a dictionary to import (%s.%s) does not correspond to the keyspace and table this manager is responsible for (%s.%s)",
                                                      dataObject.keyspace, dataObject.table,
                                                      keyspaceName, tableName));

        CompressionDictionary.Kind kind = CompressionDictionary.Kind.valueOf(dataObject.kind);

        if (this.kind != kind)
        {
            throw new IllegalArgumentException(format("It is not possible to import compression dictionaries of kind " +
                                                      "%s into table %s.%s which supports compression dictionaries of kind %s.",
                                                      kind, keyspaceName, tableName, this.kind));
        }

        CompressionDictionary.DictId dictId = new CompressionDictionary.DictId(kind, dataObject.dictId);

        LightweightCompressionDictionary latestCompressionDictionary = retrieveLightweightLatestCompressionDictionary(keyspaceName, tableName, tableId);
        if (latestCompressionDictionary != null)
        {
            if (latestCompressionDictionary.dictId.id > dictId.id)
            {
                throw new IllegalArgumentException(format("Dictionary to import has older dictionary id (%s) than the latest compression dictionary (%s) for table %s.%s",
                                                          dictId.id, latestCompressionDictionary.dictId.id, keyspaceName, tableName));
            }

            checkTrainingFrequency(latestCompressionDictionary, createTrainingConfig(Map.of()));
        }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Import a dictionary whose kind matches the table's configured dictionary compressor, or retrain the dictionary with the correct compressor.
  2. Change the table's compression to the kind matching the dictionary before importing.
  3. Verify the 'kind' string in the export exactly matches CompressionDictionary.Kind names.
  4. Keep compressor configuration consistent between source and destination clusters when copying dictionaries.

Example fix

// before
// table uses Zstd, imported dictionary kind = "Zlib"
dataObject.kind = "Zlib";
// after
dataObject.kind = manager.getCurrentKind().name(); // e.g. "Zstd" — must match table's compressor kind
Defensive patterns

Strategy: validation

Validate before calling

if (CompressionDictionary.Kind.valueOf(dataObject.kind) == manager.getCurrentKind()) manager.importCompressionDictionary(data);

Try / catch

try { manager.importCompressionDictionary(data); } catch (IllegalArgumentException e) { /* kind mismatch: retrain or realign compressor */ }

Prevention

When it happens

Trigger: Importing a dictionary whose kind enum name in the CompositeData does not equal the table's current dictionary compressor kind (this.kind != kind).

Common situations: Table compression switched between dictionary compressor types after the dictionary was exported; exporting from a cluster using one dictionary compressor and importing into a cluster configured with another; typos or wrong value in the 'kind' field of hand-built import data.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/9f7b6d1ec9e3ccf8. Report an issue: GitHub.