apache/cassandra · error · InvalidRequestException
Invalid set literal for
Error message
Invalid set literal for %s: bind variables are not supported inside collection literals
What it means
Fired during set-literal preparation when any element of a set literal is a bind marker (Terms.NON_TERMINAL containing a marker). Collection literals may only contain constants/literals, not '?' bind variables, so preparation fails immediately before element type checking.
Solutions
- Replace the bind marker (?) or named variable inside the set literal with a literal element value
- Bind the entire collection as one variable instead of individual elements inside the literal
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/java/org/apache/cassandra/cql3/terms/Sets.java:167 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/4b6b69fa540c341b.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/terms/Sets.java:167
public Term prepare(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
validateAssignableTo(keyspace, receiver);
// We've parsed empty maps as a set literal to break the ambiguity so
// handle that case now
if (receiver.type instanceof MapType && elements.isEmpty())
return new MultiElements.Value(((MapType<?, ?>) receiver.type), Collections.emptyList());
ColumnSpecification valueSpec = Sets.valueSpecOf(receiver);
List<Term> values = new ArrayList<>(elements.size());
boolean allTerminal = true;
for (Term.Raw rt : elements)
{
Term t = rt.prepare(keyspace, valueSpec);
if (t.containsBindMarker())
throw new InvalidRequestException(String.format("Invalid set literal for %s: bind variables are not supported inside collection literals", receiver.name));
if (t instanceof Term.NonTerminal)
allTerminal = false;
values.add(t);
}
MultiElements.DelayedValue value = new MultiElements.DelayedValue((MultiElementType<?>) receiver.type.unwrap(), values);
return allTerminal ? value.bind(FunctionContext.NONE) : value;
}
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
AbstractType<?> type = receiver.type.unwrap();
if (!(type instanceof SetType))
{
// We've parsed empty maps as a set literal to break the ambiguity so
// handle that case nowView on GitHub (pinned to 88fd0f6a0e)