xtrntr
01/04/2022, 7:45 AMKishore G
xtrntr
01/04/2022, 7:53 AMSELECT
f.uuid,
lookUp('dimTable', 'name', 'uuid', f.uuid) as name,
lookUp('dimTable', 'country', 'uuid', f.uuid) as country,
abs(sum(m.metric)) as sum_metric
FROM
factTable f
WHERE
f.event_time > CAST(to_unixtime(date_trunc('day', now())) AS BIGINT)
AND f.status = 'OPEN'
AND lookUp('dimTable', 'country', 'uuid', f.uuid) = 'SINGAPORE'
GROUP BY
1,
2,
3
ORDER BY
2
Kishore G
xtrntr
01/04/2022, 9:39 AMKishore G
AND f.uuid IN (select uuid from dimTable where country='SINGAPORE')
xtrntr
01/04/2022, 9:41 AMKishore G
xtrntr
01/04/2022, 9:53 AMxtrntr
01/04/2022, 9:54 AMKishore G
xtrntr
01/04/2022, 9:57 AMxtrntr
01/04/2022, 10:08 AM# factTable
-----------------
userid | raw_cell
# dimTable1
-----------------
raw_cell | mapped_cell
# dimTable2
-----------------
userid | attr1 | attr2
i can do a query like
SELECT
userid,
count(*)
FROM
factTable f
WHERE
f.raw_cell IN (select raw_cell, mapped_cell FROM dimTable1 WHERE IN_ID_SET(raw_cell, '...') = 1) AND
f.userid IN (select userid FROM dimTable2 WHERE attr1=val1 and attr2=val2)
GROUP BY
userid
?xtrntr
01/04/2022, 10:11 AMxtrntr
01/04/2022, 10:14 AMAND f.uuid IN (select uuid from dimTable where country='SINGAPORE')
do you mean
AND IN_SUBQUERY(uuid, 'select uuid from dimTable where country="SINGAPORE"')
?Kishore G
xtrntr
01/04/2022, 10:50 AMKishore G
xtrntr
01/04/2022, 11:03 AMxtrntr
01/04/2022, 11:04 AMBecause the subquery is solved as a separate query, the subquery does not necessarily hit the same table as the main query. It can retrieve the IdSet from any table served by the broker.
xtrntr
01/04/2022, 11:56 AMxtrntr
01/04/2022, 11:56 AMKishore G
xtrntr
01/07/2022, 9:37 AM