{"record":{"id":"a592c00078e3397c","repo":"apache/beam","slug":"the-primitive-hcat-type-type-of-field-name-cannot-be","errorCode":null,"errorMessage":"The Primitive HCat type '{type}' of field '{name}' cannot be converted to Beam FieldType","messagePattern":"The Primitive HCat type '(.+?)' of field '(.+?)' cannot be converted to Beam FieldType","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/SchemaUtils.java","lineNumber":76,"sourceCode":"  }\n\n  private static Schema.Field toBeamField(FieldSchema field) {\n    String name = field.getName();\n    HCatFieldSchema hCatFieldSchema;\n\n    try {\n      hCatFieldSchema = HCatSchemaUtils.getHCatFieldSchema(field);\n    } catch (HCatException e) {\n      // Converting checked Exception to unchecked Exception.\n      throw new UnsupportedOperationException(\n          \"Error while converting FieldSchema to HCatFieldSchema\", e);\n    }\n\n    switch (hCatFieldSchema.getCategory()) {\n      case PRIMITIVE:\n        {\n          if (!HCAT_TO_BEAM_TYPES_MAP.containsKey(hCatFieldSchema.getType())) {\n            throw new UnsupportedOperationException(\n                \"The Primitive HCat type '\"\n                    + field.getType()\n                    + \"' of field '\"\n                    + name\n                    + \"' cannot be converted to Beam FieldType\");\n          }\n\n          FieldType fieldType = HCAT_TO_BEAM_TYPES_MAP.get(hCatFieldSchema.getType());\n          return Schema.Field.of(name, fieldType).withNullable(true);\n        }\n        // TODO: Add Support for Complex Types i.e. ARRAY, MAP, STRUCT\n      default:\n        throw new UnsupportedOperationException(\n            \"The category '\" + hCatFieldSchema.getCategory() + \"' is not supported.\");\n    }\n  }\n}\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/SchemaUtils.java#L58-L94","documentation":"SchemaUtils.toBeamField only maps HCatalog PRIMITIVE types present in HCAT_TO_BEAM_TYPES_MAP to Beam FieldTypes. When a primitive HCat type (e.g. DECIMAL, INTERVAL, BINARY variants) has no mapping, the library refuses to silently degrade and throws UnsupportedOperationException naming the type and field.","triggerScenarios":"Reading an HCatalog table whose schema contains a primitive type outside the supported map (commonly DECIMAL, CHAR, VARCHAR, TIMESTAMP WITH LOCAL TIME ZONE) via HCatalogIO.read().","commonSituations":"Hive tables using DECIMAL(10,2) columns; tables with CHAR/VARCHAR after a Hive upgrade; reading tables designed for Hive not Beam.","solutions":["Alter the table (or a view over it) to cast unsupported columns to supported types (e.g. CAST(col AS STRING) or DOUBLE instead of DECIMAL)","Add a mapping to HCAT_TO_BEAM_TYPES_MAP in SchemaUtils if the Beam FieldType exists upstream","Filter/prune the column by copying into a staging table with supported types only","Check Beam version: newer releases may have extended the map"],"exampleFix":"-- before: table has DECIMAL amount\nCREATE VIEW t_beam AS SELECT CAST(amount AS DOUBLE) AS amount, ... FROM raw_t;\n-- after: read the view\nHCatalogIO.read().withTable(\"t_beam\")","handlingStrategy":"validation","validationCode":"boolean supported = hcatField.getCategory()==HCatFieldSchema.Category.PRIMITIVE && SchemaUtils.HCAT_TO_BEAM_TYPES_MAP.containsKey(hcatField.getType());","typeGuard":"null","tryCatchPattern":"try { ... } catch (UnsupportedOperationException e) { throw new IllegalArgumentException(\"Incompatible HCatalog primitive type; see SchemaUtils map\", e); }","preventionTips":["Avoid DECIMAL/CHAR/VARCHAR columns in tables Beam reads","Expose views with cast columns","Check HCAT_TO_BEAM_TYPES_MAP when designing table schemas","Upgrade Beam for newer type mappings"],"tags":["java","schema","hcatalog","type-mapping"],"backgroundTag":"unsupported-enum-value","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"}