Hello, I want to create tumble window over ````ev...
# troubleshooting
a
Hello, I want to create tumble window over
Copy code
`event_time` TIMESTAMP(3) METADATA FROM 'timestamp',
but I am getting error:
pyflink.util.exceptions.TableException: org.apache.flink.table.api.TableException: Window aggregate can only be defined over a time attribute column, but TIMESTAMP(3) encountered.
m
you need to define watermark on event_time
a
@Matan Perelmuter Thank you, for your help. Maybe you what I am doing wrong. If I use proc_time I see output in console, but if I switch to event_time script is running for several minutes but nothing is printed. There is only 3 records in a topic:
Copy code
t_env.execute_sql(f"""
    CREATE TABLE kafka_source (
        `event_time` TIMESTAMP(3) METADATA FROM 'timestamp',
        `topic` string METADATA FROM 'topic',
        `proc_time` AS PROCTIME(),
        WATERMARK FOR event_time AS event_time - INTERVAL '5' SECOND
    ) WITH (
        'connector' = 'kafka',
        'topic' = 'failures',
  )
  
  metrics_query = t_env.execute_sql("""
    SELECT
        topic,
        EXTRACT(EPOCH FROM TUMBLE_START(proc_time, INTERVAL '10' SECONDS)) AS window_start,
        EXTRACT(EPOCH FROM TUMBLE_END(proc_time, INTERVAL '10' SECONDS)) AS window_end,
        COUNT(*) AS topic_count
    FROM kafka_source
    GROUP BY
        TUMBLE(proc_time, INTERVAL '10' SECONDS), topic

""").print()

+----+--------------------------------+----------------------+----------------------+----------------------+
| op |                          topic |         window_start |           window_end |          topic_count |
+----+--------------------------------+----------------------+----------------------+----------------------+
| +I |          failures |           1712566460 |           1712566470 |                    3 |