2

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?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Average Bear
  • 191
  • 1
  • 3
  • 13

1 Answers1

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