{"record":{"id":"fbbee064db11c9c7","repo":"apache/beam","slug":"cannot-find-a-matching-beam-fieldtype-for-calcite-type","errorCode":null,"errorMessage":"Cannot find a matching Beam FieldType for Calcite type: ","messagePattern":"Cannot find a matching Beam FieldType for Calcite type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/CalciteUtils.java","lineNumber":273,"sourceCode":"            \"Failed to find Calcite type with name '%s'\",\n            sqlTypeName.getTypeName().getSimple()));\n  }\n\n  public static FieldType toFieldType(SqlTypeName sqlTypeName) {\n    switch (sqlTypeName) {\n      case MAP:\n      case MULTISET:\n      case ARRAY:\n      case ROW:\n        throw new IllegalArgumentException(\n            String.format(\n                \"%s is a type constructor that takes parameters, not a type,\"\n                    + \"so it cannot be converted to a %s\",\n                sqlTypeName, Schema.FieldType.class.getSimpleName()));\n      default:\n        FieldType fieldType = CALCITE_TO_BEAM_TYPE_MAPPING.get(sqlTypeName);\n        if (fieldType == null) {\n          throw new IllegalArgumentException(\n              \"Cannot find a matching Beam FieldType for Calcite type: \" + sqlTypeName);\n        }\n        return fieldType;\n    }\n  }\n\n  public static Schema.Field toField(RelDataTypeField calciteField) {\n    return toField(calciteField.getName(), calciteField.getType());\n  }\n\n  public static Schema.Field toField(String name, RelDataType calciteType) {\n    return Schema.Field.of(name, toFieldType(calciteType)).withNullable(calciteType.isNullable());\n  }\n\n  public static FieldType toFieldType(RelDataType calciteType) {\n    if (LOGICAL_TYPE_REL_DATA_MAPPING.containsKey(calciteType)) {\n      return LOGICAL_TYPE_REL_DATA_MAPPING.get(calciteType);\n    }","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/CalciteUtils.java#L255-L291","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nFieldType ft = CalciteUtils.toFieldType(SqlTypeName.SYMBOL); // throws\n// after\nFieldType ft = SqlTypeName.SYMBOL == name ? FieldType.string() : CalciteUtils.toFieldType(name);","handlingStrategy":"validation","validationCode":"if (CALCITE_TO_BEAM_TYPE_MAPPING.get(sqlTypeName) == null && !isTypeConstructor(sqlTypeName)) { /* map manually or reject column */ }","typeGuard":"boolean isBeamMappable(SqlTypeName t) {\n  return CalciteUtils.toFieldTypeQuiet(t); // or check membership in known supported set\n}","tryCatchPattern":"try { ft = CalciteUtils.toFieldType(sqlTypeName); }\ncatch (IllegalArgumentException e) { ft = FieldType.string(); /* deliberate fallback or rethrow with context */ }","preventionTips":["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"],"tags":["beam-sql","calcite","schema","type-mapping"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}