{"record":{"id":"0f496f037d9155f8","repo":"apache/druid","slug":"cannot-retrieve-map-view-from-lookup-s","errorCode":null,"errorMessage":"Cannot retrieve map view from lookup[%s]","messagePattern":"Cannot retrieve map view from lookup\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/lookup/LookupSegment.java","lineNumber":54,"sourceCode":" * querying of lookups. The lookup must support {@link LookupExtractor#asMap()}.\n */\npublic class LookupSegment extends RowBasedSegment<Map.Entry<String, String>>\n{\n  private static final RowSignature ROW_SIGNATURE =\n      RowSignature.builder()\n                  .add(LookupColumnSelectorFactory.KEY_COLUMN, ColumnType.STRING)\n                  .add(LookupColumnSelectorFactory.VALUE_COLUMN, ColumnType.STRING)\n                  .build();\n  private final String lookupName;\n\n  public LookupSegment(final String lookupName, final LookupExtractorFactory lookupExtractorFactory)\n  {\n    super(\n        Sequences.simple(() -> {\n          final LookupExtractor extractor = lookupExtractorFactory.get();\n\n          if (!extractor.supportsAsMap()) {\n            throw new ISE(\"Cannot retrieve map view from lookup[%s]\", lookupExtractorFactory);\n          }\n\n          return extractor.asMap().entrySet().iterator();\n        }),\n        new RowAdapter<>()\n        {\n          @Override\n          public ToLongFunction<Map.Entry<String, String>> timestampFunction()\n          {\n            // No timestamps for lookups.\n            return row -> 0L;\n          }\n\n          @Override\n          public Function<Map.Entry<String, String>, Object> columnFunction(String columnName)\n          {\n            if (LookupColumnSelectorFactory.KEY_COLUMN.equals(columnName)) {\n              return Map.Entry::getKey;","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/lookup/LookupSegment.java#L36-L72","documentation":"LookupSegment adapts a lookup into a queryable segment backed by a Map view of the lookup. When the underlying LookupExtractor does not support asMap() (extractor.supportsAsMap() is false), the segment's row sequence cannot be built and this ISE is thrown when iteration begins.","triggerScenarios":"Querying a global lookup datasource whose configured lookup implementation (e.g. a remote/JDBC-backed extractor) does not implement the map-view interface, whenever the segment's Sequence is actually iterated.","commonSituations":"Pointing a lookup datasource at a lookup type that lacks map support (e.g. certain cluster-extracted or remote lookups) and then running a scan/join/window query that materializes the lookup rows.","solutions":["Switch the lookup to a type that supports asMap() (e.g. an in-memory/map-backed lookup)","Load the lookup data into a table/datasource and query that instead of the lookup directly","Check extractor.supportsAsMap() before building queries against the lookup datasource"],"exampleFix":"// before\nlookupConfig: { \"myLookup\": { \"lookupExtractorFactory\": { \"type\": \"remoteFn\" } } } // no map view\n// after\nlookupConfig: { \"myLookup\": { \"lookupExtractorFactory\": { \"type\": \"mapLookupExtractorFactory\", \"map\": {...} } } }","handlingStrategy":"validation","validationCode":"LookupExtractor extractor = lookupExtractorFactory.get();\nif (!extractor.supportsAsMap()) {\n  throw new IllegalArgumentException(\"Lookup does not support map view: \" + lookupExtractorFactory);\n}","typeGuard":"boolean queryableAsSegment(LookupExtractorFactoryHolder h) {\n  return h != null && h.get() != null && h.get().supportsAsMap();\n}","tryCatchPattern":"try (Sequence<Object[]> rows = lookupSegment.readAs(...)) {\n  return rows.toList();\n} catch (IllegalStateException e) {\n  if (e.getMessage().startsWith(\"Cannot retrieve map view\")) {\n    // fall back to non-segment lookup access (lookup fn) or reconfigure\n  } else throw e;\n}","preventionTips":["Only use lookup datasources backed by map-capable extractors for segment-style queries","Check supportsAsMap() before planning queries against a lookup","Use mapLookupExtractorFactory (or dump the lookup to a table) for remote lookups"],"tags":["lookup","datasource","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}