apache/druid · error · UnsupportedOperationException

Avro + JQ not supported

Error message

Avro + JQ not supported

What it means

The Avro flattener supports JSON-path and JSON-tree-based flattening via jsonPath, but the JQ-based extraction (makeJsonQueryExtractor) is not implemented for Avro records. The interface method exists (shared flattener API), so it throws UnsupportedOperationException to indicate Avro + JQ is not a supported combination.

Source

Thrown at extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroFlattenerMaker.java:161

  {
    if (record.getSchema().getField(key) != null) {
      return transformValue(record.get(key));
    } else {
      return null;
    }
  }

  @Override
  public Function<GenericRecord, Object> makeJsonPathExtractor(final String expr)
  {
    final JsonPath jsonPath = JsonPath.compile(expr);
    return record -> transformValue(jsonPath.read(record, jsonPathConfiguration));
  }

  @Override
  public Function<GenericRecord, Object> makeJsonQueryExtractor(final String expr)
  {
    throw new UnsupportedOperationException("Avro + JQ not supported");
  }

  @Override
  public Function<GenericRecord, Object> makeJsonTreeExtractor(List<String> nodes)
  {
    if (nodes.size() == 1) {
      return (GenericRecord record) -> getRootField(record, nodes.get(0));
    }

    throw new UnsupportedOperationException("Avro + nested tree extraction not supported");
  }

  @Override
  public JsonProvider getJsonProvider()
  {
    return avroJsonProvider;
  }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Change the flattenSpec flattener to "jsonPath" or "json" (use "path"-style expressions) instead of jq.
  2. Remove the flattenSpec and instead reference Avro fields directly (root fields are supported).
  3. Pre-decode Avro to JSON in a separate step if JQ transformations are essential, then ingest the JSON.

Example fix

// before
"flattenSpec": {"useFieldDiscovery": true, "flattener": {"type": "jq", "expr": ".foo"}}
// after
"flattenSpec": {"useFieldDiscovery": true, "flattener": {"type": "jsonPath", "expr": "$.foo"}}
Defensive patterns

Strategy: validation

Validate before calling

// Validate flattenSpec before submitting an Avro ingestion job
if ("jq".equals(flattenSpec.getFlattener().getType())) {
  throw new IllegalArgumentException("jq flattener is not supported for Avro; use jsonPath or json");
}

Type guard

boolean avroSupportsFlattener(FlattenerSpec f) {
  return !"jq".equals(f.getType());
}

Try / catch

try {
  extractor = flattenerMaker.makeJsonQueryExtractor(expr);
} catch (UnsupportedOperationException e) {
  throw new IllegalArgumentException("Use jsonPath flattener for Avro inputs", e);
}

Prevention

When it happens

Trigger: Configuring an Avro inputFormat's flattenSpec (or a flattener usage) whose flattener type is "jq" — i.e. a spec with flattenSpec using JSON_QUERY-style/jq expressions — causing makeJsonQueryExtractor(String) to be invoked during field extraction.

Common situations: Copying a flattenSpec written for Kafka JSON records (which supports jq) to an Avro stream; misremembering that jq flattening works only for JSON-based formats.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/90817aa460966668. Report an issue: GitHub.