Time operations
Time units¶
The following list shows valid time units for the SIZE
, ADVANCE BY
,
SESSION
, and WITHIN
clauses.
DAY
,DAYS
HOUR
,HOURS
MINUTE
,MINUTES
SECOND
,SECONDS
MILLISECOND
,MILLISECONDS
For more information, see Windows in SQL Queries.
Timestamp formats¶
Time-based operations, like windowing, process records according to the
timestamp in ROWTIME
. By default, the implicit ROWTIME
pseudo column is the
timestamp of a message in a Kafka topic. Timestamps have an accuracy of
one millisecond.
Use the TIMESTAMP property to override ROWTIME
with the contents of
the specified column. Define the format of a record's timestamp by
using the TIMESTAMP_FORMAT property.
If you use the TIMESTAMP property but don't set TIMESTAMP_FORMAT, ksqlDB
assumes that the timestamp field is a bigint
. If you set
TIMESTAMP_FORMAT, the TIMESTAMP field must be of type varchar
and
have a format that the DateTimeFormatter
Java class can parse.
If your timestamp format has embedded single quotes, you can escape them
by using two successive single quotes, ''
. For example, to escape
'T'
, write ''T''
. The following examples show how to escape the '
character in SQL statements.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
For more information on timestamp formats, see DateTimeFormatter.