Advice on debugging a lookup issue

9 views
Skip to first unread message

Stewart Duffey

unread,
Oct 16, 2025, 11:00:26 AM (3 days ago) Oct 16
to Druid User
Hi

I'm trying to debug an issue where it appears that a lookup key is switching between two values (without being changed by an external process).

If I run a script that fetches the same value via the `LOOKUP(...)` function every 15 seconds I see a mix of the two values with no obvious pattern.

I also have a query like this, which uses the lookup value to perform currency conversion. In the example I am converting from GBP to GBP, so I would expect the initial value to be the same as the calculated result (or at least off by a tiny rounding margin).

SELECT
  ci.__time,
  ci.sum_value,
  ((sum_value / LOOKUP('<GBP>', 'currency_conversion')) * LOOKUP('<GBP>', 'currency_conversion')) AS calc_sum,
  cc.*,
  LOOKUP('<GBP>', 'currency_conversion')
FROM conversion_item AS ci
LEFT JOIN lookup.currency_conversion AS cc ON '<GBP>' = cc.k
WHERE (LOOKUP(ci.status, 'simple_status') IN ('approved', 'pending') AND ci.campaign_id = 'xxxxx')
AND (__time BETWEEN '2025-09-01T00:00:00' AND '2025-09-30T23:59:59')
LIMIT 50000

The value retrieved via the `LOOKUP` function is consistent, but the value retrieved via the lookup join varies between the same two values. In cases where the function value and the join value match the calculated value is accurate, where they do not match the calculated value is incorrect.

So it looks like this is happening:
((sum_value / LOOKUP('<GBP>', 'currency_conversion')) * LOOKUP('<GBP>', 'currency_conversion')) AS calc_sum
is translated into 
((sum_value / VALUE_A) * VALUE_B) AS calc_sum
 
I'm not sure where to go next, any advice would be greatly appreciated

Many thanks!
Reply all
Reply to author
Forward
0 new messages