Skip to content

Aligning Tumbling Window Aggregations to Full Hours #2824

Answered by ngjaying
kriskonina asked this question in Q&A
Discussion options

You must be logged in to vote

@kriskonina Sounds like you want to use event time.

When creating stream, specify the timestamp field for it. Example like

{
  "sql": "create stream jsonDemo () WITH (TYPE=\"mqtt\", FORMAT=\"json\", SHARED=\"TRUE\", DATASOURCE=\"demo\", TIMESTAMP=\"ts\")"
}

In your rule, need to set its option isEventTime to true

{
  "id": "rule3",
  "sql": "SELECT * FROM jsonDemo GROUP BY TumblingWindow(hh, 1)",
  "actions": [
    {
      "mqtt": {
        "server": "tcp://127.0.0.1:1883",
        "topic": "result/rule3"
      }
    }
  ],
  "options": {
    "isEventTime": true,
    "lateTolerance": 0
  }
}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by kriskonina
Comment options

You must be logged in to vote
1 reply
@ngjaying
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants