apache/druid · error · UnsupportedOperationException (UOE)

Unsupported resultFormat for array-based results

Error message

Unsupported resultFormat for array-based results: %s

What it means

getResultFormatMapper only supports array-based result formats that have a defined row mapper. Any other ScanQuery.ResultFormat value reaching this switch is rejected with an UnsupportedOperationException.

Solutions

  1. Use one of the supported result formats for array-based results (RESULT_FORMAT_VALUE_VECTOR aside, typically RESULT_FORMAT_COMPACTED_LIST) or route list-format results through their dedicated mapper path.
  2. If a new ResultFormat was added, upgrade Druid so the format mapper supports it.
  3. Verify no custom code passes a null or custom ResultFormat into getResultFormatMapper.

Example fix

// before
ScanQuery q = query.withResultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_LIST);
Sequence<Object[]> rows = toolChest.getResultFormatMapper(q.getResultFormat()).apply(sv);
// after
ScanQuery q = query.withResultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST);
Sequence<Object[]> rows = toolChest.getResultFormatMapper(q.getResultFormat()).apply(sv);
Defensive patterns

Strategy: validation

Validate before calling

EnumSet.of(ResultFormat.RESULT_FORMAT_COMPACTED_LIST, ResultFormat.RESULT_FORMAT_LIST).contains(query.getResultFormat());

Type guard

boolean isArrayBasedFormat(ScanQuery.ResultFormat f) {
  return f == ResultFormat.RESULT_FORMAT_COMPACTED_LIST;
}

Try / catch

try {
  mapper = toolChest.getResultFormatMapper(format);
} catch (UnsupportedOperationException e) {
  // fall back to RESULT_FORMAT_COMPACTED_LIST
}

Prevention

When it happens

Trigger: Calling getResultFormatMapper (directly or via resultsAsFrames/mapper) with a resultFormat other than the supported array-based formats (e.g. RESULT_FORMAT_LIST, which is handled elsewhere, or a format added by an extension without a corresponding mapper).

Common situations: Extension or downstream code passing an unknown ResultFormat; version mismatches where a new ResultFormat enum constant is used against an older Druid core; misuse of the QueryToolChest API in tests.

Related errors


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

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/scan/ScanQueryQueryToolChest.java:304

          return rowArray;
        };
        break;
      case RESULT_FORMAT_COMPACTED_LIST:
        mapper = (List<Object> row) -> {
          if (row.size() == fields.size()) {
            return row.toArray();
          } else if (fields.isEmpty()) {
            return new Object[0];
          } else {
            // Uh oh... mismatch in expected and actual field count. I don't think this should happen, so let's
            // throw an exception. If this really does happen, and there's a good reason for it, then we should remap
            // the result row here.
            throw new ISE("Mismatch in expected[%d] vs actual[%s] field count", fields.size(), row.size());
          }
        };
        break;
      default:
        throw new UOE("Unsupported resultFormat for array-based results: %s", resultFormat);
    }
    return mapper;
  }
}

View on GitHub (pinned to 9b90983fd2)