{"record":{"id":"36b1d37dce354084","repo":"apache/beam","slug":"cannot-find-a-matching-calcite-sqltypename-for-beam-type-s","errorCode":null,"errorMessage":"Cannot find a matching Calcite SqlTypeName for Beam type: %s","messagePattern":"Cannot find a matching Calcite SqlTypeName for Beam 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":243,"sourceCode":"          if (logicalType != null) {\n            if (logicalType instanceof PassThroughLogicalType) {\n              // for pass through logical type, just return its base type\n              return toSqlTypeName(logicalType.getBaseType());\n            } else if (Timestamp.IDENTIFIER.equals(logicalType.getIdentifier())) {\n              return SqlTypeName.TIMESTAMP;\n            } else if (\"SqlCharType\".equals(logicalType.getIdentifier())) {\n              LOG.warn(\n                  \"SqlCharType is used in Schema. It was removed in Beam 2.44.0 and should be\"\n                      + \" replaced by FixedString logical type.\");\n              return SqlTypeName.CHAR;\n            } else {\n              throw new IllegalArgumentException(\n                  String.format(\n                      \"Cannot find a matching Calcite SqlTypeName for Beam logical type: %s\",\n                      logicalType.getIdentifier()));\n            }\n          }\n          throw new IllegalArgumentException(\n              String.format(\"Cannot find a matching Calcite SqlTypeName for Beam type: %s\", type));\n        } else {\n          return typeName;\n        }\n    }\n  }\n\n  public static FieldType toFieldType(SqlTypeNameSpec sqlTypeName) {\n    return toFieldType(\n        Preconditions.checkArgumentNotNull(\n            SqlTypeName.get(sqlTypeName.getTypeName().getSimple()),\n            \"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:","sourceCodeStart":225,"sourceCodeEnd":261,"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#L225-L261","documentation":"In CalciteUtils.toSqlTypeName, if a Schema.TypeName falls into the default case and has no direct Calcite SqlTypeName counterpart, IllegalArgumentException 'Cannot find a matching Calcite SqlTypeName for Beam type: %s' is thrown. It means a Beam primitive/atomic type cannot be represented in Calcite's type system for SQL planning.","triggerScenarios":"Passing a Schema.FieldType whose TypeName (e.g. BYTE_ARRAY in some paths, ROW without prior handling, DATETIME variants, or any unsupported TypeName) reaches the default branch of toSqlTypeName.","commonSituations":"Creating tables or deriving RelDataType from a schema that contains types Beam SQL cannot map (e.g. logical/logical-row types added after CalciteUtils was written), or hand-built schemas used with SqlTransform.","solutions":["Replace the unsupported FieldType with a SQL-mappable type (string, int64, double, timestamp, etc.).","Wrap complex types as ROW/ARRAY/MAP explicitly via the supported SQL mappings.","Log and skip such fields before building the SQL schema.","Upgrade Beam — mapping coverage grows over versions."],"exampleFix":"// before\nSchema.Field.of(\"blob\", FieldType.varbinary()) // may be unmapped in older Beam\n// after\nSchema.Field.of(\"blob\", FieldType.bytes.withNullable(true)) // or a supported type","handlingStrategy":"try-catch","validationCode":"if (!Set.of(TypeName.BYTE, TypeName.INT16, TypeName.INT32, TypeName.INT64, TypeName.FLOAT, TypeName.DOUBLE, TypeName.DECIMAL, TypeName.STRING, TypeName.BOOLEAN, TypeName.DATETIME).contains(fieldType.getTypeName())) { /* handle before conversion */ }","typeGuard":"boolean isCalciteMappable(Schema.TypeName t) {\n  return switch (t) { case BYTE, INT16, INT32, INT64, FLOAT, DOUBLE, DECIMAL, STRING, BOOLEAN, DATETIME -> true; default -> false; };\n}","tryCatchPattern":"try { rel = CalciteUtils.toRelDataType(fieldType, typeFactory); }\ncatch (IllegalArgumentException e) { /* skip field or map to nearest supported type */ }","preventionTips":["Restrict SQL-exposed schemas to primitive SQL-representable types","Model complex data as ROW/ARRAY/MAP explicitly","Test schema -> RelDataType conversion in CI for all table schemas","Keep Beam upgraded for expanded type coverage"],"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"}