来自t-sql的条件延迟

a8jjtwal  于 2021-05-26  发布在  Spark
关注(0)|答案(0)|浏览(302)

我正在尝试将一些代码从transact-sql从azure stream analytics迁移到本地环境,到目前为止,我尝试了pyspark,但结果都满足要求。问题是我们不能在上面加when条款。我想用pyspark或任何开源语言来做这个。优选流处理
作为输入数据,我有如下内容:

ID_PAINEL  STATE      ID_EVENT_LOG
------------------------------
2          LIGADO     40
1          LIGADO     50
1          SOMETHING  
1          TEST  
1          DESLIGADO  
1          LIGADO     60
1          SOMETHING  
1          TEST
2          SOMETHING    
2          TEST  
3          SOMETHING
3          TEST

我在azure stream analytics上拥有的代码:

[arranq_disp_unique] AS (SELECT *, CASE
                                WHEN  LAG(ID_EVENT_LOG) OVER (PARTITION BY ID_PAINEL LIMIT DURATION(minute, 10) WHEN STATE LIKE 'LIGADO%') is null then id_painel
                                ELSE LAG(ID_EVENT_LOG) OVER (PARTITION BY ID_PAINEL LIMIT DURATION(minute, 10) WHEN STATE LIKE 'LIGADO%') 
                                END AS UNIQUE_PAR
                            FROM [classify_reconnection_success]

预期产量:

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题