apache/druid · error · UnsupportedOperationException

Cannot get map view

Error message

Cannot get map view

What it means

PollingLookup.asMap() is unimplemented: a polling lookup is backed by an external data source that is periodically reloaded, so it deliberately refuses to expose a full map view. Any code that requests the whole lookup contents as a Map hits this UnsupportedOperationException.

Solutions

  1. Read the underlying data source (CSV/JSON/URL feed) directly to enumerate entries
  2. Use a map-backed lookup implementation if a full map view is required
  3. Guard generic code with lookup.canIterate()/supportsAsMap checks before calling asMap()
Defensive patterns

Strategy: type-guard

Type guard

boolean canExportAsMap(LookupExtractor l) { return !(l instanceof PollingLookup); }

Try / catch

try { return lookup.asMap(); } catch (UnsupportedOperationException e) { return exportFromDataSource(lookup); }

Prevention

When it happens

Trigger: Invoking asMap() on a polling (cached-single) lookup — e.g. code paths that dump lookup contents, bulk-export lookups, or the lookup introspection API.

Common situations: Trying to dump lookup contents via tooling or the /druid/coordinator/v1/lookups introspection paths; code written generically over MapLookupExtractionFnResolvingLookup that assumes asMap() always works.

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/5896cf78116b8c8b. Report an issue: GitHub.

Appendix: source

Thrown at extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/PollingLookup.java:171

      return cache.getKeys(value);
    }
    finally {
      if (cache != null) {
        cacheRefKeeper.doneWithIt();
      }
    }
  }

  @Override
  public boolean supportsAsMap()
  {
    return false;
  }

  @Override
  public Map<String, String> asMap()
  {
    throw new UnsupportedOperationException("Cannot get map view");
  }

  @Override
  public byte[] getCacheKey()
  {
    return LookupExtractionModule.getRandomCacheKey();
  }

  private Runnable pollAndSwap()
  {
    return new Runnable()
    {
      @Override
      public void run()
      {
        LOGGER.debug("Polling and swapping of PollingLookup [%s]", id);
        CacheRefKeeper newCacheKeeper = new CacheRefKeeper(cacheFactory.makeOf(dataFetcher.fetchAll()));
        CacheRefKeeper oldCacheKeeper = refOfCacheKeeper.getAndSet(newCacheKeeper);

View on GitHub (pinned to 9b90983fd2)