Sorry, I mean "could not".
-- Best! Xuyang 在 2024-07-10 15:21:48,"Xuyang" <xyzhong...@163.com> 写道: Hi, which Flink version does you use? I could re-produce this bug in master. My test sql is below: ``` CREATE TABLE UNITS_DATA( proctime AS PROCTIME() , `IDENT` INT , `STEPS_ID` INT , `ORDERS_ID` INT ) WITH ( 'connector' = 'datagen', 'fields.STEPS_ID.min' = '64911', 'fields.STEPS_ID.max' = '64912', 'rows-per-second' = '1' ); WITH current_and_previous as ( SELECT proctime , ud.STEPS_ID as STEPS_ID , ud.IDENT as UNITS_DATA_ID , ud.ORDERS_ID as ORDERS_ID , LAG(ud.ORDERS_ID, 1) OVER (PARTITION BY STEPS_ID ORDER BY proctime) PREV_ORDERS_ID FROM UNITS_DATA ud WHERE STEPS_ID=64911 ) select * from current_and_previous; ``` The result is as expected: ``` +----+-------------------------+-------------+---------------+-------------+----------------+ | op | proctime | STEPS_ID | UNITS_DATA_ID | ORDERS_ID | PREV_ORDERS_ID | +----+-------------------------+-------------+---------------+-------------+----------------+ | +I | 2024-07-10 15:19:17.661 | 64911 | -772065898 | 342255977 | <NULL> | | +I | 2024-07-10 15:19:20.651 | 64911 | 1165938984 | 162006411 | 342255977 | | +I | 2024-07-10 15:19:22.614 | 64911 | -1000903042 | -2059780314 | 162006411 | ``` -- Best! Xuyang 在 2024-07-09 14:22:08,"Brandl, Johann" <johann.bra...@zollner.de> 写道: Hi everyone, i’m new to flink and tried some queries with flink sql. Currently I have a problem with the LAG function. I want to emit a new record when the ORDERS_ID changes. To do this, I use the LAG function to detect whether this has changed. However, I noticed that every now and then I cannot access the ORDERS_ID of the previous message. It seems to have to do with the proctime I use in the ORDER BY with LAG. As soon as the proctime changes in the range of seconds, I cannot access the last value and gives me NULL. Do any of you know what this could be? Here is the query I use: CREATE TABLE UNITS_DATA( proctime AS PROCTIME() , `IDENT` DOUBLE , `STEPS_ID` DOUBLE , `ORDERS_ID` DOUBLE ) WITH ( 'connector' = 'kafka', 'topic' = 'UNITS_DATA', 'properties.bootstrap.servers' = 'http://myserver:9094', 'scan.startup.mode' = 'latest-offset', 'format' = 'avro-confluent', 'avro-confluent.url' = 'http://myserver:8080/apis/ccompat/v6/' ); WITH current_and_previous as ( SELECT proctime , ud.STEPS_ID as STEPS_ID , ud.IDENT as UNITS_DATA_ID , ud.ORDERS_ID as ORDERS_ID , LAG(ud.ORDERS_ID, 1) OVER (PARTITION BY STEPS_ID ORDER BY proctime) PREV_ORDERS_ID FROM UNITS_DATA ud WHERE STEPS_ID=64911 ) select * from current_and_previous; Thanks in advance and best regards Zollner Elektronik AG Manfred-Zollner-Str. 1, 93499 Zandt, GERMANY / Phone: +49 9944 201-0 / Fax: +49 9944 201-1314 / i...@zollner.de / www.zollner.de Registered office of the company: Zandt / Registration court Regensburg HRB 8354 Managing Board: Ludwig Zollner (Spokesman of the Board) / Manfred Zollner jun. / Christian Zollner / Thomas Schreiner / Markus Aschenbrenner Supervisory Board: Manfred Zollner sen. (Chairman) Wichtiger Hinweis: Diese E-Mail enthält vertrauliche Informationen. Wenn Sie diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Die Anfertigung unerlaubter Kopien, die Weitergabe der Information sowie die unbefugte Weitersendung der E-Mail ist nicht gestattet. Weiterführend können Hinweise zur Verarbeitung Ihrer personenbezogenen Daten (nach Art. 13 und 14 Datenschutzgrundverordnung - DSGVO) unter dem folgenden Link abgerufen werden: https://www.zollner.de/datenschutz-verarbeitungsverzeichnis-extern Important note: This e-mail contains confidential information. If you received this e-mail by mistake, please inform the sender immediately and destroy this e-mail. The making of unauthorized copies, the passing on of the information and the unauthorized forwarding of the e-mail is not permitted. Furhermore information about the processing of your personal Information (according to art. 13 and 14 general data protection regulation - GDPR) can be retrieved on the page: https://www.zollner-electronics.com/en/data-protection-processing-directory-external