# タイムウィンドウ関数

# tumble

tumbleは、固定の期間(interval)で連続しない、重複しないウィンドウにレコードを割り当てます。

tumble(time_attr, interval [, timezone])

引数

  • time_attr - 日付と時刻。DateTimeデータ型。
  • interval - ウィンドウの期間。Intervalデータ型。
  • timezone — タイムゾーン名(オプション)。

返される値

  • 対応するtumblingウィンドウの包括的な下限と排他的な上限。
  • 型: Tuple(DateTime, DateTime)

SELECT tumble(now(), toIntervalDay('1'))
┌─tumble(now(), toIntervalDay('1'))─────────────┐
│ ('2023-10-27 00:00:00','2023-10-28 00:00:00') │
└───────────────────────────────────────────────┘

# hop

hopは、固定の期間(window_interval)でホップし、指定されたホップ間隔(hop_interval)でホップするホッピングウィンドウです。hop_intervalwindow_intervalよりも小さい場合、ホッピングウィンドウは重複します。したがって、レコードは複数のウィンドウに割り当てられることがあります。

hop(time_attr, hop_interval, window_interval [, timezone])

引数

  • time_attr - 日付と時刻。DateTimeデータ型。
  • hop_interval - ホップ間隔。Intervalデータ型。正の数である必要があります。
  • window_interval - ウィンドウの期間。Intervalデータ型。正の数である必要があります。
  • timezone — タイムゾーン名(オプション)。

返される値

  • 対応するホッピングウィンドウの包括的な下限と排他的な上限。1つのレコードが複数のホップウィンドウに割り当てられることがあるため、ホップ関数がWINDOW VIEWなしで使用される場合、関数は最初のウィンドウの境界のみを返します。
  • 型: Tuple(DateTime, DateTime)

SELECT hop(now(), INTERVAL '1' SECOND, INTERVAL '2' SECOND)
┌─hop(now(), toIntervalSecond('1'), toIntervalSecond('2'))──┐
│ ('2023-10-27 15:10:17','2023-10-27 15:10:19')             │
└───────────────────────────────────────────────────────────┘

# tumbleStart

対応するtumblingウィンドウの包括的な下限を返します。

tumbleStart(bounds_tuple);
tumbleStart(time_attr, interval [, timezone]);

# tumbleEnd

対応するtumblingウィンドウの排他的な上限を返します。

tumbleEnd(bounds_tuple);
tumbleEnd(time_attr, interval [, timezone]);

# hopStart

対応するhoppingウィンドウの包括的な下限を返します。

hopStart(bounds_tuple);
hopStart(time_attr, hop_interval, window_interval [, timezone]);

# hopEnd

対応するhoppingウィンドウの排他的な上限を返します。

hopEnd(bounds_tuple);
hopEnd(time_attr, hop_interval, window_interval [, timezone]);
Last Updated: Thu Apr 11 2024 02:40:52 GMT+0000