apache/druid · error · IllegalStateException

Cannot retrieve map view from lookup

Error message

Cannot retrieve map view from lookup[%s]

What it means

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.

Solutions

  1. Switch the lookup to a type that supports asMap() (e.g. an in-memory/map-backed lookup)
  2. Load the lookup data into a table/datasource and query that instead of the lookup directly
  3. Check extractor.supportsAsMap() before building queries against the lookup datasource

Example fix

// before
lookupConfig: { "myLookup": { "lookupExtractorFactory": { "type": "remoteFn" } } } // no map view
// after
lookupConfig: { "myLookup": { "lookupExtractorFactory": { "type": "mapLookupExtractorFactory", "map": {...} } } }
Defensive patterns

Strategy: validation

Validate before calling

LookupExtractor extractor = lookupExtractorFactory.get();
if (!extractor.supportsAsMap()) {
  throw new IllegalArgumentException("Lookup does not support map view: " + lookupExtractorFactory);
}

Type guard

boolean queryableAsSegment(LookupExtractorFactoryHolder h) {
  return h != null && h.get() != null && h.get().supportsAsMap();
}

Try / catch

try (Sequence<Object[]> rows = lookupSegment.readAs(...)) {
  return rows.toList();
} catch (IllegalStateException e) {
  if (e.getMessage().startsWith("Cannot retrieve map view")) {
    // fall back to non-segment lookup access (lookup fn) or reconfigure
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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/0f496f037d9155f8. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/lookup/LookupSegment.java:54

 * querying of lookups. The lookup must support {@link LookupExtractor#asMap()}.
 */
public class LookupSegment extends RowBasedSegment<Map.Entry<String, String>>
{
  private static final RowSignature ROW_SIGNATURE =
      RowSignature.builder()
                  .add(LookupColumnSelectorFactory.KEY_COLUMN, ColumnType.STRING)
                  .add(LookupColumnSelectorFactory.VALUE_COLUMN, ColumnType.STRING)
                  .build();
  private final String lookupName;

  public LookupSegment(final String lookupName, final LookupExtractorFactory lookupExtractorFactory)
  {
    super(
        Sequences.simple(() -> {
          final LookupExtractor extractor = lookupExtractorFactory.get();

          if (!extractor.supportsAsMap()) {
            throw new ISE("Cannot retrieve map view from lookup[%s]", lookupExtractorFactory);
          }

          return extractor.asMap().entrySet().iterator();
        }),
        new RowAdapter<>()
        {
          @Override
          public ToLongFunction<Map.Entry<String, String>> timestampFunction()
          {
            // No timestamps for lookups.
            return row -> 0L;
          }

          @Override
          public Function<Map.Entry<String, String>, Object> columnFunction(String columnName)
          {
            if (LookupColumnSelectorFactory.KEY_COLUMN.equals(columnName)) {
              return Map.Entry::getKey;

View on GitHub (pinned to 9b90983fd2)