apache/druid · error · UnsupportedOperationException

cannot perform lookup when applying an extraction function

Error message

cannot perform lookup when applying an extraction function

What it means

The dictionary-encoded column's lookupId(String) view throws UnsupportedOperationException when an extraction function was supplied to the column selector, because dictionary ids refer to raw values and cannot be used to look up values after extraction. This is an intentional guard in the anonymous IndexedTable/Dictionary lookup wrapper.

Solutions

  1. Create the column/dimension selector without an extractionFn when dictionary-id lookup is needed
  2. Apply the extraction after lookupId instead of via extractionFn
  3. Check whether the selector exposes an extraction function and fall back to value-based lookup

Example fix

// before
DimensionSelector sel = column.makeDimensionSelector(new ExtractionDimensionSpec(spec, extractionFn));
int id = sel.lookupId(name);
// after
DimensionSelector sel = column.makeDimensionSelector(spec);
int id = sel.lookupId(name); // apply extractionFn to sel.lookupName(id) afterwards if needed
Defensive patterns

Strategy: validation

Validate before calling

if (selectorDimExtractionFn == null) { int id = dict.lookupId(name); } else { /* compare post-extraction values instead */ }

Type guard

boolean supportsLookupId(DimensionSelector sel) { try { sel.lookupId(null); return true; } catch (UnsupportedOperationException e) { return false; } } // prefer: check extractionFn at construction

Try / catch

try { return dict.lookupId(name); } catch (UnsupportedOperationException e) { return lookupByValue(name, extractionFn); }

Prevention

When it happens

Trigger: Calling lookupId(name) on the dictionary object obtained from makeDimensionSelector/lookup machinery when the column was created with a non-null extractionFn.

Common situations: Filter/extraction code that assumes raw-dictionary lookups; join or lookup planning that ignores the extraction function applied to a dimension.

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/35f5047491ac5288. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/segment/column/StringUtf8DictionaryEncodedColumn.java:207

      @Override
      public boolean nameLookupPossibleInAdvance()
      {
        return true;
      }

      @Nullable
      @Override
      public IdLookup idLookup()
      {
        return extractionFn == null ? this : null;
      }

      @Override
      public int lookupId(String name)
      {
        if (extractionFn != null) {
          throw new UnsupportedOperationException("cannot perform lookup when applying an extraction function");
        }
        return StringUtf8DictionaryEncodedColumn.this.lookupId(name);
      }
    }

    if (hasMultipleValues()) {
      class MultiValueDimensionSelector extends QueryableDimensionSelector
      {
        @Override
        public IndexedInts getRow()
        {
          return multiValueColumn.get(offset.getOffset());
        }

        @Override
        public IndexedInts getRow(int offset)
        {
          return multiValueColumn.get(offset);

View on GitHub (pinned to 9b90983fd2)