ARRAY_CONTAINS is perfect to check if an array contains a particular value. There is also a WHERE ANY WITHIN SATISFIES loop; is there a shortcut way to compare if any array contains ANY values from another array? The solution we have currently:
WHERE
ANY x WITHIN y
SATISFIES
ANY a WITHIN b
SATISFIES
ARRAY_CONTAINS(a.field1, x.field1) OR
ARRAY_CONTAINS(a.field2, x.field2)
END
END
Query
SELECT ARRAY_AGG(product.product.sku) AS blocklist
FROM default product USE KEYS [“PR_890256”, “PR_577281”]
NEST default blocked ON KEYS [“BR_0001018242001NAT”]
WHERE
ANY sku WITHIN product
SATISFIES
ANY blockRule WITHIN blocked
SATISFIES
ARRAY_CONTAINS(blockRule.skulist, sku.sku)
END
END
Not sure if you’ve already solved this, but could you use ARRAY_INTERSECT to do this simply? If it returns an empty array, then no values overlap, so any non-empty array means at least some values overlap (and you’d also know which values overlapped, if that ever mattered).