{"record":{"id":"d917aaff3465acd6","repo":"apache/beam","slug":"cannot-find-a-matching-calcite-sqltypename-for-beam-logical","errorCode":null,"errorMessage":"Cannot find a matching Calcite SqlTypeName for Beam logical type: %s","messagePattern":"Cannot find a matching Calcite SqlTypeName for Beam logical 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":237,"sourceCode":"          // This will happen e.g. if looking up a STRING type, and metadata isn't set to say which\n          // type of SQL string we want. In this case, use the default mapping.\n          typeName = BEAM_TO_CALCITE_DEFAULT_MAPPING.get(type);\n        }\n        if (typeName == null) {\n          Schema.LogicalType<?, ?> logicalType = type.getLogicalType();\n          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'\",","sourceCodeStart":219,"sourceCodeEnd":255,"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#L219-L255","documentation":"CalciteUtils.toSqlTypeName maps Beam Schema types (and legacy logical types) to Calcite SqlTypeName. When a FieldType carries a logical type whose identifier has no known mapping, IllegalArgumentException is thrown with the logical type identifier. This usually means a logical type Beam SQL does not recognize (or a pre-2.44 removed type that is not SqlCharType).","triggerScenarios":"toSqlTypeName(FieldType) or toRelDataType with a FieldType whose getLogicalType().getIdentifier() is not one of the handled identifiers (and is not a base type handled by the switch).","commonSituations":"Using custom logical types registered by the application in a Beam SQL schema; upgrading Beam where a logical type was renamed/removed (e.g. types removed in 2.44 like SqlCharType's siblings); passing non-SQL-compatible logical types such as etc/UTC datetime or enumeration variants.","solutions":["Replace the custom/legacy logical type with a SQL-representable FieldType (e.g. StringType, FixedString, int64).","If you hit a legacy removed type, migrate per the Beam 2.44 migration notes (SqlCharType -> FixedString).","Register mapping support by switching on the identifier in your own copy/extension of CalciteUtils.","Inspect schema fields and strip logical types before feeding Beam SQL."],"exampleFix":"// before\nSchema.Field.of(\"name\", FieldType.logicalType(new SqlCharType()))\n// after\nSchema.Field.of(\"name\", FieldType.logicalType(FixedString.of(10)))","handlingStrategy":"try-catch","validationCode":"String id = fieldType.getLogicalType() != null ? fieldType.getLogicalType().getIdentifier() : null;\nif (id != null && !SUPPORTED_LOGICAL_IDS.contains(id)) { /* replace or drop field before SQL */ }","typeGuard":"boolean isSqlCompatible(FieldType ft) {\n  return ft.getLogicalType() == null || Set.of(\"FixedString\", \"SqlCharType\", \"Enumeration\", ...).contains(ft.getLogicalType().getIdentifier());\n}","tryCatchPattern":"try { sqlTypeName = CalciteUtils.toSqlTypeName(fieldType); }\ncatch (IllegalArgumentException e) { /* substitute a supported FieldType, e.g. FieldType.string() */ }","preventionTips":["Avoid custom logical types in schemas fed to Beam SQL","Migrate legacy removed logical types (Beam 2.44: SqlCharType -> FixedString)","Normalize schemas before table creation","Pin Beam versions when relying on logical-type mappings"],"tags":["beam-sql","calcite","schema","logical-type"],"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"}