{"record":{"id":"3a31df7c467b34ea","repo":"apache/druid","slug":"avro-nested-tree-extraction-not-supported","errorCode":null,"errorMessage":"Avro + nested tree extraction not supported","messagePattern":"Avro \\+ nested tree extraction not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroFlattenerMaker.java","lineNumber":171,"sourceCode":"  {\n    final JsonPath jsonPath = JsonPath.compile(expr);\n    return record -> transformValue(jsonPath.read(record, jsonPathConfiguration));\n  }\n\n  @Override\n  public Function<GenericRecord, Object> makeJsonQueryExtractor(final String expr)\n  {\n    throw new UnsupportedOperationException(\"Avro + JQ not supported\");\n  }\n\n  @Override\n  public Function<GenericRecord, Object> makeJsonTreeExtractor(List<String> nodes)\n  {\n    if (nodes.size() == 1) {\n      return (GenericRecord record) -> getRootField(record, nodes.get(0));\n    }\n\n    throw new UnsupportedOperationException(\"Avro + nested tree extraction not supported\");\n  }\n\n  @Override\n  public JsonProvider getJsonProvider()\n  {\n    return avroJsonProvider;\n  }\n\n  @Override\n  public Object finalizeConversionForMap(Object o)\n  {\n    return transformValue(o);\n  }\n\n  private Object transformValue(final Object field)\n  {\n    if (fromPigAvroStorage && field instanceof GenericArray) {\n      return Lists.transform((List) field, item -> String.valueOf(((GenericRecord) item).get(0)));","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroFlattenerMaker.java#L153-L189","documentation":"Avro flattening can extract a single root field by name, but traversing nested JSON-tree node paths (nodes.size() > 1) is not implemented for Avro records, so makeJsonTreeExtractor throws UnsupportedOperationException for nested paths.","triggerScenarios":"A flattenSpec with \"type\": \"json\" (tree) flattener and an expression containing multiple path nodes (nested extraction, e.g. \"a.b.c\") applied to an Avro input format — the first single-node case works, anything deeper throws.","commonSituations":"Reusing nested-tree flatten specs designed for JSON data sources against Avro streams; users expecting JmesPath/tree navigation inside Avro unions/records.","solutions":["Use the \"jsonPath\" flattener with a $.a.b.c path expression instead of the tree flattener for nested fields.","Flatten only root fields (single-node tree expressions) or reference Avro sub-fields via jsonPath.","Restructure the ingestion: decode Avro to JSON first, then apply nested tree extraction on the JSON format."],"exampleFix":"// before\n{\"flattener\": {\"type\": \"json\", \"fieldName\": \"event.a.b\"}}\n// after\n{\"flattener\": {\"type\": \"jsonPath\", \"expr\": \"$.event.a.b\"}}","handlingStrategy":"validation","validationCode":"if (\"json\".equals(flattener.getType()) && expr.split(\"\\\\.\").length > 1) {\n  throw new IllegalArgumentException(\"Nested tree extraction unsupported for Avro; use jsonPath\");\n}","typeGuard":"boolean isSimpleTreeExpr(FlattenerSpec f) {\n  return !\"json\".equals(f.getType()) || f.getFieldName().indexOf('.') < 0;\n}","tryCatchPattern":"try {\n  extractor = flattenerMaker.makeJsonTreeExtractor(nodes);\n} catch (UnsupportedOperationException e) {\n  extractor = flattenerMaker.makeJsonPropertyExtractor(joinWithDollarPath(nodes));\n}","preventionTips":["Keep tree-flattener expressions to a single root-field node for Avro sources.","Use jsonPath ($.a.b.c) for nested Avro fields.","Document format-specific flattener limits in ingestion spec templates."],"tags":["java","avro","flattener","nested-fields"],"backgroundTag":"unsupported-operation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}