Repository navigation
Description
What happened?
Map key discovery returns an empty list when the mergeTreeTextIndex query fails, instead of falling through to the rollup and bounded-scan paths.
This breaks key discovery on tables with row policies. ClickHouse refuses mergeTreeTextIndex with ACCESS_DENIED whenever a row policy applies to the table (ClickHouse/ClickHouse#119032), and getMapKeys turns that error into []. The bounded mapKeys scan, which reads the table itself and respects row policies, never runs. Search bar autocomplete shows no keys for those Map columns.
Expected: if the text-index query fails, getMapKeys should log and try the next strategy, the same way it already does when the index query succeeds but returns no keys.
The short-circuit is in both catch blocks in getMapKeys:
- key index: https://github.com/hyperdxio/hyperdx/blob/b52adf71/packages/common-utils/src/core/metadata.ts#L1030-L1036
- kv index: https://github.com/hyperdxio/hyperdx/blob/b52adf71/packages/common-utils/src/core/metadata.ts#L1070-L1076
The other text-index readers (getMapTextIndexKeyValues, getTextIndexKeyValues) already skip the failed strategy and continue, so this would make getMapKeys consistent with them.
The bug only shows when the user can read system.data_skipping_indices. Without that grant, HyperDX doesn't detect the text index and goes straight to the scan, which works.
The only workaround today is dropping the *_attr_key / *_attr_kv text indexes on the protected tables. That moves discovery to the scan path but makes key loading slower for everyone using those tables. There's no per-source setting to skip the text index for key discovery.
Related: #2880 hits the same short-circuit with a different error (BAD_ARGUMENTS on Distributed tables).
Steps to reproduce
- On ClickHouse 26.8.15 (any release with Text index: make
mergeTreeTextIndexstricter when a row policy applies ClickHouse#119032), createotel_logsfrom the seed schema, which includesidx_log_attr_keyonmapKeys(LogAttributes), and insert rows from two services with differentLogAttributeskeys. - Create a user with
GRANT SELECT ON default.*andGRANT SELECT ON system.data_skipping_indices, and a row policy on the table for that user:CREATE ROW POLICY api_only ON default.otel_logs USING ServiceName = 'api' TO rp_user. - Add a HyperDX connection as that user and a log source on
otel_logs. - On the search page, type
LogAttributes.in the search bar. No keys are suggested. The same source on a connection as thedefaultuser suggests all keys.
How are you running HyperDX?
Reported on HyperDX 2.39.1. Reproduced on a local dev stack at main (b52adf7) with ClickHouse 26.8.15.10.
Where does it show up?
UI: search bar autocomplete for Map attribute columns (verified). Other features that use getMapKeys are likely affected too.
Debug info
N/A
Logs
Browser console during the reproduction:
getMapKeys rollup query failed for key text index query ClickHouseQueryError: Cannot read from `mergeTreeTextIndex` because a row policy is applied on table default.otel_logs (<uuid>). The text index covers all rows of the table, so reading its tokens would violate the row policy.
Activity
[HDX-5598] fix(common-utils): fall through to mapKeys scan when text …