apache/beam · error · SqlConversionException
SQL type not supported:
Error message
SQL type not supported:
What it means
When converting a Calcite RexLiteral into a CEPLiteral, only a fixed set of SQL types (e.g. INTEGER, BIGINT, DOUBLE, DECIMAL, BOOLEAN, DATE, CHAR/VARCHAR) is supported; any other type name falls into the default branch and raises SqlConversionException with the unsupported type name. Beam SQL's CEP translation cannot represent that literal.
Solutions
- Cast the literal to a supported type in the query, e.g. CAST(ts AS TIMESTAMP) only if supported, or restructure to compare supported types (BIGINT epoch millis, VARCHAR, DOUBLE, BOOLEAN, DATE)
- Replace the unsupported literal with a supported equivalent (e.g. epoch-millis BIGINT instead of TIMESTAMP)
- Rewrite the DEFINE condition to avoid the unsupported literal type entirely
Example fix
// before DEFINE x AS event_time > TIMESTAMP '2020-01-01 00:00:00' -- unsupported // after DEFINE x AS event_ts > 1577836800000 -- BIGINT epoch millis literal
Defensive patterns
Strategy: validation
Validate before calling
SqlTypeName tn = lit.getTypeName();
Set<SqlTypeName> supported = Set.of(SqlTypeName.INTEGER, SqlTypeName.BIGINT, SqlTypeName.DOUBLE,
SqlTypeName.DECIMAL, SqlTypeName.BOOLEAN, SqlTypeName.DATE, SqlTypeName.CHAR, SqlTypeName.VARCHAR);
if (!supported.contains(tn)) throw new IllegalArgumentException("Unsupported CEP literal type: " + tn); Type guard
static boolean isSupportedCepLiteralType(RexLiteral lit) {
switch (lit.getTypeName()) {
case INTEGER: case BIGINT: case DOUBLE: case DECIMAL:
case BOOLEAN: case DATE: case CHAR: case VARCHAR:
return true;
default:
return false;
}
} Try / catch
try {
CEPLiteral l = CEPLiteral.of(lit);
} catch (SqlConversionException e) {
if (e.getMessage().startsWith("SQL type not supported")) {
throw new IllegalStateException("Replace literal of type " + lit.getTypeName() + " in DEFINE clause", e);
} else throw e;
} Prevention
- Use BIGINT/DOUBLE/VARCHAR/BOOLEAN/DATE literals in CEP DEFINE clauses
- Avoid TIMESTAMP/TIME/INTERVAL/ARRAY literals in MATCH_RECOGNIZE patterns
- Cast or convert literals to supported types before pattern matching
When it happens
Trigger: Using a literal in a MATCH_RECOGNIZE DEFINE clause whose Calcite SqlTypeName is outside the supported switch cases, e.g. TIMESTAMP, TIME, INTERVAL, ARRAY, or ANY-typed literals.
Common situations: Comparing pattern variables against TIMESTAMP/TIME literals in CEP DEFINE clauses; using typed empty arrays or interval literals in pattern conditions; Calcite inferring an unexpected type (e.g. DECIMAL vs DOUBLE) for a numeric literal.
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
- RexNode not supported:
- Cannot find a matching Beam FieldType for Calcite type:
- Cannot find a matching Calcite SqlTypeName for Beam logical…
- Cannot find a matching Calcite SqlTypeName for Beam type
- Cannot infer types from
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/d425e14a4b317cbe.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/cep/CEPLiteral.java:61
case INTEGER:
return of(lit.getValueAs(Integer.class));
case BIGINT:
return of(lit.getValueAs(Long.class));
case DECIMAL:
return of(lit.getValueAs(BigDecimal.class));
case FLOAT:
return of(lit.getValueAs(Float.class));
case DOUBLE:
return of(lit.getValueAs(Double.class));
case BOOLEAN:
return of(lit.getValueAs(Boolean.class));
case DATE:
return of(lit.getValueAs(ReadableDateTime.class));
case CHAR:
case VARCHAR:
return of(lit.getValueAs(String.class));
default:
throw new SqlConversionException("SQL type not supported: " + lit.getTypeName().toString());
}
}
public static CEPLiteral of(Byte myByte) {
return new CEPLiteral(Schema.TypeName.BYTE) {
@Override
public Byte getByte() {
return myByte;
}
@Override
public int compareTo(Object other) {
if (!(other instanceof CEPLiteral)) {
throw new IllegalStateException("The other object should be an instance of CEPLiteral");
}
CEPLiteral otherLit = (CEPLiteral) other;
if (getTypeName() != otherLit.getTypeName()) {
throw new IllegalStateException(View on GitHub (pinned to 12126d8942)