Can we count the elements arriving within a window of 5 mins in Spark structure streaming?

We cannot simply run the count method on a streaming DataFrame, since it is not supported. However, we can apply this method after a groupBy operation. So, to get the count of the number of rows in a batch, we can apply the group by operation on the window start time and count the number of rows in the result.