{"record":{"id":"14219d3b79618383","repo":"apache/beam","slug":"unable-to-convert-typename","errorCode":null,"errorMessage":"Unable to convert ${typeName}","messagePattern":"Unable to convert (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamCalcRel.java","lineNumber":472,"sourceCode":"          }\n          return LocalDateTime.of(\n              LocalDate.ofEpochDay(((Number) value).longValue() / MILLIS_PER_DAY),\n              LocalTime.ofNanoOfDay(\n                  (((Number) value).longValue() % MILLIS_PER_DAY) * NANOS_PER_MILLISECOND));\n        } else if (org.apache.beam.sdk.schemas.logicaltypes.Timestamp.IDENTIFIER.equals(\n            identifier)) {\n          if (value instanceof Timestamp) {\n            value = SqlFunctions.toLong((Timestamp) value);\n          }\n          return java.time.Instant.ofEpochMilli(((Number) value).longValue());\n        } else {\n          if (logicalType instanceof PassThroughLogicalType) {\n            return toBeamObject(value, logicalType.getBaseType(), verifyValues);\n          }\n          throw new UnsupportedOperationException(\"Unable to convert logical type \" + identifier);\n        }\n      default:\n        throw new UnsupportedOperationException(\"Unable to convert \" + fieldType.getTypeName());\n    }\n  }\n\n  private static List<Object> toBeamList(\n      List<Object> arrayValue, FieldType elementType, boolean verifyValues) {\n    return arrayValue.stream()\n        .map(e -> toBeamObject(e, elementType, verifyValues))\n        .collect(Collectors.toList());\n  }\n\n  private static Map<Object, Object> toBeamMap(\n      Map<Object, Object> mapValue,\n      FieldType keyType,\n      FieldType elementType,\n      boolean verifyValues) {\n    Map<Object, Object> output = new HashMap<>(mapValue.size());\n    for (Map.Entry<Object, Object> entry : mapValue.entrySet()) {\n      output.put(","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamCalcRel.java#L454-L490","documentation":"Fallback branch of toBeamObject: when a Schema Field's TypeName has no mapping to a Calcite value type (e.g. certain row/nested or exotic types unsupported by the SQL bridge), this UnsupportedOperationException is thrown with the type name. It signals that Beam SQL cannot represent that field type in its row conversion.","triggerScenarios":"Querying a table whose schema contains a field type unsupported by the SQL extension (e.g. certain nested STRUCT/ROW layouts or map variants in some Beam versions) so the switch in toBeamObject reaches default.","commonSituations":"Beam SQL over a PCollection with complex nested schemas; schemas inferred from Avro/protobuf with types the SQL extension hasn't mapped; older Beam versions lacking support for newer schema types.","solutions":["Flatten or restructure the schema so only SQL-supported types (primitives, arrays, maps, simple logical types) remain before the query","Select only supported columns in the SQL statement","Convert unsupported fields to supported types (e.g. serialize nested structs to JSON strings) beforehand","Upgrade Beam — type coverage in the SQL extension grows across releases"],"exampleFix":"// before\nPCollection<Row> out = p.apply(SqlTransform.query(\"SELECT nested_col FROM t\"));\n// after\nRow flattened = row.getValue(\"nested_col\"); // extract/flatten before SQL, or select supported fields","handlingStrategy":"type-guard","validationCode":"boolean allFieldsSupported(Schema s) {\n  return s.getFields().stream().allMatch(f ->\n    java.util.Set.of(BOOLEAN,BYTE,INT16,INT32,INT64,FLOAT,DOUBLE,STRING,DATETIME)\n      .contains(f.getType().getTypeName()) || f.getType().isCollectionType() || f.getType().isMapType());\n}","typeGuard":"boolean isFlatPrimitive(Schema.FieldType t) {\n  return !t.isNestedType() && t.getLogicalType() == null;\n}","tryCatchPattern":"try {\n  rows.apply(SqlTransform.query(sql));\n} catch (UnsupportedOperationException e) {\n  // project out/flatten the offending field and retry\n}","preventionTips":["Flatten nested structs before SQL stages","Avoid inferring schemas directly from Avro/Proto for SQL inputs without review","Test queries against representative schemas in CI","Upgrade Beam when new schema types are introduced"],"tags":["java","apache-beam","sql","schema","type-mismatch"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}