apache/cassandra · error · SyntaxException

FrozenType() only accepts one parameter

Error message

FrozenType() only accepts one parameter

What it means

FrozenType.getInstance() parses a CQL type specification via TypeParser and requires exactly one nested type parameter, because frozen<T> wraps a single inner type. When the parser returns zero or multiple parameters (e.g. 'FrozenType()' or 'frozen<int, text>'), a SyntaxException with this message is thrown. It is a type-specification grammar error, not a data error.

Source

Thrown at src/java/org/apache/cassandra/db/marshal/FrozenType.java:45

import org.apache.cassandra.serializers.MarshalException;
import org.apache.cassandra.serializers.TypeSerializer;
import org.apache.cassandra.transport.ProtocolVersion;

/**
 * A fake type that is only used for parsing type strings that include frozen types.
 */
public class FrozenType extends AbstractType<Void>
{
    protected FrozenType()
    {
        super(ComparisonType.NOT_COMPARABLE);
    }

    public static AbstractType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
    {
        List<AbstractType<?>> innerTypes = parser.getTypeParameters();
        if (innerTypes.size() != 1)
            throw new SyntaxException("FrozenType() only accepts one parameter");

        AbstractType<?> innerType = innerTypes.get(0);
        return innerType.freeze();
    }

    public <V> String getString(V value, ValueAccessor<V> accessor)
    {
        throw new UnsupportedOperationException();
    }

    public ByteBuffer fromString(String source) throws MarshalException
    {
        throw new UnsupportedOperationException();
    }

    public Term fromJSONObject(Object parsed) throws MarshalException
    {
        throw new UnsupportedOperationException();

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Provide exactly one inner type: frozen<map<text, int>>, frozen<list<int>>, etc.
  2. Remove empty or extra type arguments from the type string
  3. For a collection, freeze the whole collection (frozen<map<..>>) rather than passing multiple parameters
  4. Wrap TypeParser.parse calls in try-catch for SyntaxException and surface the offending type string

Example fix

// before
CREATE TABLE t (k int PRIMARY KEY, v frozen<int, text>);
// after
CREATE TABLE t (k int PRIMARY KEY, v frozen<tuple<int, text>>);
Defensive patterns

Strategy: validation

Validate before calling

List<AbstractType<?>> params = parser.getTypeParameters();
if (params.size() != 1) throw new IllegalArgumentException("frozen<> requires exactly one type parameter");

Type guard

static boolean isWellFormedFrozenSpec(String typeSpec) { return typeSpec.matches("(?i)frozen\\s*<[^<>]+>"); }

Try / catch

try { AbstractType<?> t = FrozenType.getInstance(parser); } catch (SyntaxException e) { /* fix the type string: exactly one inner type */ }

Prevention

When it happens

Trigger: Parsing a type string like 'FrozenType()' or 'frozen<a, b>' via TypeParser.parse (e.g. in CREATE TABLE / ALTER TYPE parsing or AbstractType.parse) where getTypeParameters() does not yield exactly one inner type.

Common situations: Typos in CQL schema definitions (empty frozen<>); hand-written type strings in yaml or tools that build types programmatically; copy-paste of multi-arg generic syntax like frozen<map<text,int>> written as frozen<map<text,int>, something>.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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