apache/cassandra · error · InvalidRequestException

Missing target column

Error message

Missing target column

What it means

StorageAttachedIndex.validateOptions throws InvalidRequestException("Missing target column") when the index options contain no 'target' entry. An SAI index must declare the column it indexes; without a target the index has nothing to build over.

Source

Thrown at src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java:250

                unknown.put(option.getKey(), option.getValue());
            }
        }

        if (!unknown.isEmpty())
        {
            return unknown;
        }

        if (ILLEGAL_PARTITIONERS.contains(metadata.partitioner.getClass()))
        {
            throw new InvalidRequestException("Storage-attached index does not support the following IPartitioner implementations: " + ILLEGAL_PARTITIONERS);
        }

        String targetColumn = options.get(IndexTarget.TARGET_OPTION_NAME);

        if (targetColumn == null)
        {
            throw new InvalidRequestException("Missing target column");
        }

        if (targetColumn.split(",").length > 1)
        {
            throw new InvalidRequestException("A storage-attached index cannot be created over multiple columns: " + targetColumn);
        }

        Pair<ColumnMetadata, IndexTarget.Type> target = TargetParser.parse(metadata, targetColumn);

        if (target == null)
        {
            throw new InvalidRequestException("Failed to retrieve target column for: " + targetColumn);
        }

        // In order to support different index targets on non-frozen map, ie. KEYS, VALUE, ENTRIES, we need to put index
        // name as part of index file name instead of column name. We only need to check that the target is different
        // between indexes. This will only allow indexes in the same column with a different IndexTarget.Type.
        //

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Specify the column: CREATE CUSTOM INDEX idx ON ks.tbl (col) USING 'StorageAttachedIndex'
  2. If constructing IndexMetadata in code, set options with IndexTarget.TARGET_OPTION_NAME
  3. Check generated schema statements for a missing column list

Example fix

// before
CREATE CUSTOM INDEX idx ON ks.tbl () USING 'StorageAttachedIndex';
// after
CREATE CUSTOM INDEX idx ON ks.tbl (email) USING 'StorageAttachedIndex';
Defensive patterns

Strategy: validation

Validate before calling

String target = indexOptions.get("target");
if (target == null || target.isBlank()) throw new IllegalArgumentException("SAI index requires a target column");

Try / catch

try { session.execute(ddl); } catch (InvalidRequestException e) { if (e.getMessage().equals("Missing target column")) { /* fix DDL to include a column */ } else throw e; }

Prevention

When it happens

Trigger: CREATE CUSTOM INDEX with USING StorageAttachedIndex but no column in the index specification, or options map constructed programmatically without the target option.

Common situations: Programmatic IndexMetadata construction omitting IndexTarget.TARGET_OPTION_NAME; corrupted/hand-edited schema; driver or tooling bug generating the CREATE INDEX statement.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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