apache/beam · error · IllegalArgumentException
Cannot find a matching Beam FieldType for Calcite type:
Error message
Cannot find a matching Beam FieldType for Calcite type:
What it means
After excluding type constructors, toFieldType(SqlTypeName) looks up CALCITE_TO_BEAM_TYPE_MAPPING; if a Calcite SqlTypeName has no Beam FieldType entry, IllegalArgumentException 'Cannot find a matching Beam FieldType for Calcite type: <name>' is thrown. This indicates a Calcite type Beam SQL never mapped.
Solutions
- Map the type manually to a supported Beam FieldType before conversion.
- Narrow the input types to those Beam SQL supports (numeric, char, binary, boolean, date/time, NULL).
- Extend CALCITE_TO_BEAM_TYPE_MAPPING if you own the fork.
- Catch the IllegalArgumentException and provide a fallback FieldType.
Example fix
// before FieldType ft = CalciteUtils.toFieldType(SqlTypeName.SYMBOL); // throws // after FieldType ft = SqlTypeName.SYMBOL == name ? FieldType.string() : CalciteUtils.toFieldType(name);
Defensive patterns
Strategy: validation
Validate before calling
if (CALCITE_TO_BEAM_TYPE_MAPPING.get(sqlTypeName) == null && !isTypeConstructor(sqlTypeName)) { /* map manually or reject column */ } Type guard
boolean isBeamMappable(SqlTypeName t) {
return CalciteUtils.toFieldTypeQuiet(t); // or check membership in known supported set
} Try / catch
try { ft = CalciteUtils.toFieldType(sqlTypeName); }
catch (IllegalArgumentException e) { ft = FieldType.string(); /* deliberate fallback or rethrow with context */ } Prevention
- Restrict external Calcite schemas to Beam-supported types
- Maintain an explicit allowlist of accepted SqlTypeNames
- Log unmapped types during schema ingestion
- Catch and wrap with column context before propagating
When it happens
Trigger: Calling CalciteUtils.toFieldType(SqlTypeName) with an unmapped atomic SqlTypeName (e.g. exotic Calcite types like ANY, CURSOR, SYMBOL, DISTINCT types, or INTERVAL in older Beam versions).
Common situations: Round-tripping RelDataTypes produced by third-party Calcite adapters (e.g. Drill/Phoenix dialects) into Beam schemas; using Calcite-only type names not exposed by Beam SQL.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Cannot find a matching Calcite SqlTypeName for Beam type
- Cannot find a matching Calcite SqlTypeName for Beam logical…
- is a type constructor that takes parameters, not a type,so…
- Cannot infer types from
- columnsMapping ' ' does not fit to schema field names
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/fbbee064db11c9c7.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/CalciteUtils.java:273
"Failed to find Calcite type with name '%s'",
sqlTypeName.getTypeName().getSimple()));
}
public static FieldType toFieldType(SqlTypeName sqlTypeName) {
switch (sqlTypeName) {
case MAP:
case MULTISET:
case ARRAY:
case ROW:
throw new IllegalArgumentException(
String.format(
"%s is a type constructor that takes parameters, not a type,"
+ "so it cannot be converted to a %s",
sqlTypeName, Schema.FieldType.class.getSimpleName()));
default:
FieldType fieldType = CALCITE_TO_BEAM_TYPE_MAPPING.get(sqlTypeName);
if (fieldType == null) {
throw new IllegalArgumentException(
"Cannot find a matching Beam FieldType for Calcite type: " + sqlTypeName);
}
return fieldType;
}
}
public static Schema.Field toField(RelDataTypeField calciteField) {
return toField(calciteField.getName(), calciteField.getType());
}
public static Schema.Field toField(String name, RelDataType calciteType) {
return Schema.Field.of(name, toFieldType(calciteType)).withNullable(calciteType.isNullable());
}
public static FieldType toFieldType(RelDataType calciteType) {
if (LOGICAL_TYPE_REL_DATA_MAPPING.containsKey(calciteType)) {
return LOGICAL_TYPE_REL_DATA_MAPPING.get(calciteType);
}View on GitHub (pinned to 12126d8942)