{"record":{"id":"9f2d3887a2f53d5a","repo":"apache/druid","slug":"unsupported-resultformat-for-array-based-results","errorCode":null,"errorMessage":"Unsupported resultFormat for array-based results: %s","messagePattern":"Unsupported resultFormat for array-based results: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException (UOE)","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/scan/ScanQueryQueryToolChest.java","lineNumber":304,"sourceCode":"          return rowArray;\n        };\n        break;\n      case RESULT_FORMAT_COMPACTED_LIST:\n        mapper = (List<Object> row) -> {\n          if (row.size() == fields.size()) {\n            return row.toArray();\n          } else if (fields.isEmpty()) {\n            return new Object[0];\n          } else {\n            // Uh oh... mismatch in expected and actual field count. I don't think this should happen, so let's\n            // throw an exception. If this really does happen, and there's a good reason for it, then we should remap\n            // the result row here.\n            throw new ISE(\"Mismatch in expected[%d] vs actual[%s] field count\", fields.size(), row.size());\n          }\n        };\n        break;\n      default:\n        throw new UOE(\"Unsupported resultFormat for array-based results: %s\", resultFormat);\n    }\n    return mapper;\n  }\n}\n","sourceCodeStart":286,"sourceCodeEnd":309,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/scan/ScanQueryQueryToolChest.java#L286-L309","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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.","If a new ResultFormat was added, upgrade Druid so the format mapper supports it.","Verify no custom code passes a null or custom ResultFormat into getResultFormatMapper."],"exampleFix":"// before\nScanQuery q = query.withResultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_LIST);\nSequence<Object[]> rows = toolChest.getResultFormatMapper(q.getResultFormat()).apply(sv);\n// after\nScanQuery q = query.withResultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST);\nSequence<Object[]> rows = toolChest.getResultFormatMapper(q.getResultFormat()).apply(sv);","handlingStrategy":"validation","validationCode":"EnumSet.of(ResultFormat.RESULT_FORMAT_COMPACTED_LIST, ResultFormat.RESULT_FORMAT_LIST).contains(query.getResultFormat());","typeGuard":"boolean isArrayBasedFormat(ScanQuery.ResultFormat f) {\n  return f == ResultFormat.RESULT_FORMAT_COMPACTED_LIST;\n}","tryCatchPattern":"try {\n  mapper = toolChest.getResultFormatMapper(format);\n} catch (UnsupportedOperationException e) {\n  // fall back to RESULT_FORMAT_COMPACTED_LIST\n}","preventionTips":["Only call getResultFormatMapper for array-based formats.","Pin client and server Druid versions so enum constants match.","Never pass null ResultFormat into the mapper."],"tags":["druid","scan-query","unsupported-operation"],"backgroundTag":"unsupported-enum-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}