{"record":{"id":"09368bef8efc5bbb","repo":"apache/beam","slug":"unreachable-case-for-beam-typename-s","errorCode":null,"errorMessage":"Unreachable case for Beam typename %s","messagePattern":"Unreachable case for Beam typename (.+?)","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamEnumerableConverter.java","lineNumber":376,"sourceCode":"                .map(elem -> fieldToAvatica(type.getCollectionElementType(), elem))\n                .collect(Collectors.toList());\n      case ITERABLE:\n        return StreamSupport.stream(((Iterable<?>) beamValue).spliterator(), false)\n            .map(elem -> fieldToAvatica(type.getCollectionElementType(), elem))\n            .collect(Collectors.toList());\n      case MAP:\n        return ((Map<?, ?>) beamValue)\n            .entrySet().stream()\n                .collect(\n                    Collectors.toMap(\n                        entry -> entry.getKey(),\n                        entry ->\n                            fieldToAvatica(type.getCollectionElementType(), entry.getValue())));\n      case ROW:\n        // TODO: needs to be a Struct\n        return beamValue;\n      default:\n        throw new IllegalStateException(\n            String.format(\"Unreachable case for Beam typename %s\", type.getTypeName()));\n    }\n  }\n\n  private static Enumerable<Object> count(PipelineOptions options, BeamRelNode node) {\n    Pipeline pipeline = Pipeline.create(options);\n    BeamSqlRelUtils.toPCollection(pipeline, node).apply(ParDo.of(new RowCounter()));\n    PipelineResult result = pipeline.run();\n\n    long count = 0;\n    if (!containsUnboundedPCollection(pipeline)) {\n      if (PipelineResult.State.FAILED.equals(result.waitUntilFinish())) {\n        throw new RuntimeException(\"Pipeline failed for unknown reason\");\n      }\n      MetricQueryResults metrics =\n          result\n              .metrics()\n              .queryMetrics(","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamEnumerableConverter.java#L358-L394","documentation":"fieldToAvatica switches over Beam FieldType.getTypeName() to produce JDBC-friendly values. The default branch is supposed to be unreachable because all Beam TypeNames are handled; hitting IllegalStateException(\"Unreachable case for Beam typename %s\") means a FieldType with a TypeName the converter doesn't recognize reached the row-conversion path — typically a new/custom or logical element type added after this code was written.","triggerScenarios":"SELECTing a column (or nested collection/row element) whose Beam FieldType TypeName falls through the switch — e.g. a recently added Beam TypeName, an exotic logical-typed field inside arrays/maps, or a schema produced by custom IO connectors.","commonSituations":"Upgrading Beam SDK so schemas contain new types while the SQL extension converter lags behind; using custom logical types in table schemas queried through the JDBC/Calcite interface; returning POJO/Avro-derived schemas with unusual field types from a SELECT.","solutions":["Identify the offending TypeName from the message and change the column type to a supported primitive (INT32, STRING, DATETIME, etc.) in the schema","Avoid exotic logical types in columns exposed to Beam SQL; cast/coerce to supported types upstream","File/apply an upstream fix adding a case for the missing TypeName in fieldToAvatica","Check Beam SDK version compatibility between the component producing the schema and the SQL extension"],"exampleFix":"// before: schema with unsupported field\nSchema schema = Schema.builder().addInt64Field(\"id\").addFieldType(\"x\", unsupportedType).build();\n// after: coerce to a supported type\nSchema schema = Schema.builder().addInt64Field(\"id\").addStringField(\"x\").build();","handlingStrategy":"type-guard","validationCode":"for (Field f : schema.getFields()) {\n  switch (f.getType().getTypeName()) {\n    case BYTE: case INT16: case INT32: case INT64: case FLOAT: case DOUBLE:\n    case STRING: case DATETIME: case BOOLEAN: case DECIMAL: case ARRAY:\n    case MAP: case ITERABLE: case ROW:\n      break;\n    default:\n      throw new IllegalArgumentException(\"Field '\" + f.getName()\n          + \"' has unsupported type \" + f.getType().getTypeName());\n  }\n}","typeGuard":"static final Set<TypeName> SUPPORTED = EnumSet.of(TypeName.BYTE, TypeName.INT16,\n    TypeName.INT32, TypeName.INT64, TypeName.FLOAT, TypeName.DOUBLE, TypeName.STRING,\n    TypeName.DATETIME, TypeName.BOOLEAN, TypeName.DECIMAL, TypeName.ARRAY,\n    TypeName.MAP, TypeName.ITERABLE, TypeName.ROW);\nboolean isAvaticaConvertible(FieldType t) { return SUPPORTED.contains(t.getTypeName()); }","tryCatchPattern":"try {\n  Object v = fieldToAvatica(type, value);\n} catch (IllegalStateException e) {\n  if (e.getMessage().startsWith(\"Unreachable case for Beam typename\")) {\n    // coerce value to string/primitive or skip field\n  } else throw e;\n}","preventionTips":["Keep query schemas limited to primitive Beam types","Coerce POJO/Avro-derived schemas to supported types before SELECT","Pin consistent Beam versions across schema-producing components and the SQL extension","Test JDBC SELECT round-trip over every column in the schema","Track upstream Beam issues for unhandled TypeNames in fieldToAvatica"],"tags":["java","beam","sql","avatica","type-mismatch","schema"],"backgroundTag":"type-mismatch","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"}