Repository navigation
Description
Summary
When a source points at a Distributed table, all metadata queries that use the text-index fast path fail. Index discovery correctly resolves Distributed → local table, but index reads pass the Distributed name to mergeTreeTextIndex(...), which only accepts a MergeTree table.
Version: HyperDX 2.32.0 (also present in 2.34.0 and main), ClickHouse 26.7.3.19, multi-shard cluster.
What happens
Source = observability.otel_traces (Distributed → observability.otel_traces_local, which has INDEX idx_span_attr_items SpanAttributeItems TYPE text(tokenizer = 'array')).
HyperDX generates:
SELECT splitByString('=', token)[1] AS key
FROM mergeTreeTextIndex('observability', 'otel_traces', 'idx_span_attr_items')
WHERE part_name IN (SELECT name FROM system.parts
WHERE database = 'observability' AND table = 'otel_traces' AND active = 1 AND ...)
GROUP BY key HAVING key != '' LIMIT 1000Code: 36. DB::Exception: There is no index with name 'idx_span_attr_items'. (BAD_ARGUMENTS)
Root cause
In packages/common-utils/src/core/metadata.ts, two places keep the Distributed table name:
mergeTreeTextIndex(databaseName, tableName, index)at L708, L744, L1204, L1281 — whilegetSkipIndicesalready resolves the local table + cluster viagetDistributedTableArgs(feat: Support fetching table metadata for Distributed tables #1920, feat: Support fetching distributed table metadata with cluster() #1944).partsOverlapFilter(L618) filterssystem.partsby the same name — a Distributed table has no parts there, so even with the index name fixed the predicate would be empty.
Impact
The error is only console.warn-ed, so the UI shows nothing — but there is no fallback for the affected columns:
getMapKeysreturns[]from its catch block (L726) instead of falling through to the MV/scan tiers → noSpanAttributes['…']keys in autocomplete or the field picker.determineKeyValueFetchingStrategyassigns one strategy per column, so columns routed to the text index never reach the existing kv rollup MV → no filter values for those columns.- Affects logs too (
otel_logsis Distributed;otel_logs_localhasidx_log_attr_items,idx_res_attr_items,idx_scope_attr_items,idx_trace_id).
Search/filtering still works — the has(SpanAttributeItems, 'key=value') rewrite runs as normal SQL on the shards. Only metadata is broken.
Proposed fix
Use the already-resolved local table and wrap the table function in cluster(), and build partsOverlapFilter on the local table name. Verified on a live 26.7 cluster (returns 277 keys where the current query throws):
SELECT splitByString('=', token)[1] AS key
FROM cluster('{cluster}', mergeTreeTextIndex('observability','otel_traces_local','idx_span_attr_items'))
WHERE part_name IN (SELECT name FROM system.parts
WHERE database = 'observability' AND table = 'otel_traces_local' AND active = 1)
GROUP BY key HAVING key != ''Passing {cluster} as a literal works — querySkipIndices already relies on it.
Separately, the getMapKeys catch blocks should fall through to the MV/scan tiers instead of returning [], so a text-index failure degrades gracefully.
Activity
Vansh98789 commentedon Aug 17, 2026
Hi @telperions
Fixed in #2930 - thanks for the detailed root-cause writeup, it made this straightforward to track down and fix.
The PR resolves both root causes:
mergeTreeTextIndex(...)calls ingetMapKeys,getMapTextIndexKeyValues, andgetTextIndexKeyValuesnow resolve theDistributedtable to its underlying local table + cluster (reusing the samegetDistributedTableArgspatterngetSkipIndicesalready uses) and wrap the table function incluster(...), matching your proposed fix.partsOverlapFilternow builds itssystem.partspredicate against the resolved local table name instead of the Distributed name.Also included:
getMapKeys's text-indexcatchblocks no longerreturn []on failure — they now fall through to the MV/raw-table-scan tiers, so a text-index failure degrades gracefully instead of silently returning no keys, as you suggested.Added regression tests covering:
mergeTreeTextIndex/system.partscorrectly targeting the resolved local table +cluster()for a Distributed sourceBAD_ARGUMENTSgetAllKeyValuesrouting a Distributed-source column through the fixed text-index path end-to-endVerified against your repro shape (Distributed table wrapping a local
otel_traces_local/otel_logs_localwith theidx_span_attr_items/idx_log_attr_itemstext indexes) — the generated SQL now matches thecluster(...)form from your proposed fix.[HDX-5598] fix(common-utils): fall through to mapKeys scan when text …