apache/beam · error · java.lang.IllegalArgumentException
[ ] is not valid.
Error message
[%s] is not valid.
What it means
Beam SQL's aggregation rule converter only accepts Calcite RexLiteral operands when extracting a long value (e.g. for window duration parameters). If the operand is any other RexNode type (e.g. a RexCall or RexInputRef), it throws IllegalArgumentException because it cannot statically evaluate it to a number.
Solutions
- Replace the duration/offset operand with a constant SQL literal, e.g. INTERVAL '1' MINUTE
- Precompute the value in application code and inline it into the query
- Check the Calcite version; CALCITE-2837 tracks simplifying this literal handling
Example fix
// before SELECT COUNT(*) FROMPCOLLECTION GROUP BY TUMBLE(ts, my_duration_column) // after SELECT COUNT(*) FROM PCOLLECTION GROUP BY TUMBLE(ts, INTERVAL '1' MINUTE)
Defensive patterns
Strategy: validation
Validate before calling
if (!(operand instanceof RexLiteral)) { throw new IllegalArgumentException("Duration must be a SQL interval literal"); } Type guard
boolean isLiteral(RexNode n) { return n instanceof RexLiteral; } Try / catch
try { ... } catch (IllegalArgumentException e) { /* fall back to literal-only windowing */ } Prevention
- Always pass constant interval literals for window parameters
- Avoid computed expressions in GROUP BY window functions
- Pin Calcite/Beam versions together
When it happens
Trigger: Passing a non-literal expression where a numeric literal is required, e.g. TUMBLE(interval_column, duration_expression) where the duration is a column reference or computed expression instead of a constant literal.
Common situations: Windowing SQL queries where the user writes an interval as a computed expression or a referenced field rather than an inline literal like INTERVAL '60' SECOND; also seen after Calcite version changes alter how literals are represented.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Attempting to create database
- Attempting to 'USE CATALOG
- Encountered an unexpected node type
- Getting operands CREATE TABLE is unsupported at the moment
- Predicate node ' ' should be a boolean expression, but was
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/4b5b19f19e887e32.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rule/BeamAggregationRule.java:208
"Specifying alignment (offset) is not supported for session windows");
}
return sessions;
default:
return null;
}
}
private static Duration durationParameter(List<RexNode> parameters, int parameterIndex) {
return Duration.millis(longValue(parameters.get(parameterIndex)));
}
private static long longValue(RexNode operand) {
if (operand instanceof RexLiteral) {
// @TODO: this can be simplified after CALCITE-2837
return ((Number) RexLiteral.value(operand)).longValue();
} else {
throw new IllegalArgumentException(String.format("[%s] is not valid.", operand));
}
}
}
View on GitHub (pinned to 12126d8942)