How do I check if there are more than two records in a stream that are from the same userId but with a different productId. Lets say we have stream (uid,pid,price) I want to emit if from the same uid there are multiple different pid. What is the correct query syntax if pid is a string?
Asked
Active
Viewed 2,059 times
1 Answers
0
use count_distinct operator
SELECT COUNT_DISTINCT(PID), uid
FROM product_stream WINDOW TUMBLING (SIZE 5 SECONDS) GROUP BY uid
HAVING COUNT_DISTINCT(PID) > 1 EMIT CHANGES;

Average Bear
- 191
- 1
- 3
- 13