app_remove操作的延迟导致结果集为空。

huangapple go评论50阅读模式
英文:

lag of app_remove giving null result set

问题

你好,以下是您的翻译:

我正在尝试找出每个用户在移除应用之前的最后3个事件。
以下是我目前的代码:

select
    lag(event_name,3) over(partition by user_pseudo_id order by event_timestamp) as lag_event_name_3,
    lag(event_name,2) over(partition by user_pseudo_id order by event_timestamp) as lag_event_name_2,
    lag(event_name) over(partition by user_pseudo_id order by event_timestamp) as lag_event_name
    from table_name
    where event_name = 'app_remove'
    and user_pseudo_id in (select * from dataset)

问题在于我得到了一个空的结果集。我是否漏掉了什么?谢谢。

英文:

I am trying to figure out the last 3 events before app removal for each user.
Here is my code so far:

   select
    lag(event_name,3) over(partition by user_pseudo_id order by event_timestamp) as lag_event_name_3,
    lag(event_name,2) over(partition by user_pseudo_id order by event_timestamp) as lag_event_name_2,
    lag(event_name) over(partition by user_pseudo_id order by event_timestamp) as lag_event_name
    from table_name
    where event_name = 'app_remove'
    and user_pseudo_id in (select * from dataset)

The problem is that I am getting a null result set. Am I missing something here? Thanks

答案1

得分: 0

将此建议作为@nbk的答案添加,以供社区查看。

在选择子句中添加另一个字段,以填充由于分区记录而导致的空值。

选择事件名称,lag(event_name,3)...

窗口函数的良好参考资料在这里:https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls#def_window_spec

英文:

Adding this suggestion as answer by @nbk for the visibility of the community.

Adding another field in the select clause to fill the null values due to partitioned records.

>SELECT event_name, lag(event_name,3)...

A good reference for window functions here: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls#def_window_spec

huangapple
  • 本文由 发表于 2023年6月25日 19:11:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76550116.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定