【发布时间】:2021-11-01 05:53:08
【问题描述】:
我在查询中有以下语句在 Presto 中运行良好:
CASE
WHEN cte_v1.id_agent is not null
THEN cte_v1.id_agent
WHEN cte_v1.id_agent is null
and lead(cte_v1.interaction_channel,1) ignore nulls over(partition by id_ticket, interaction_channel order by cte_v1.interaction_start_time) = 'messaging'
THEN lead(cte_v1.id_agent,1) ignore nulls over(partition by id_ticket, interaction_channel order by cte_v1.interaction_start_time)
END as agent
但是,当我尝试在 Hive 中操作此查询时,我收到以下错误 '失败:ParseException 第 12:39 行在语句中的 'nulls' 附近的 'ignore' 处缺少 KW_THEN'
如前所述,此查询在 Presto 中运行良好,并通过重新创建 id_agent 列并用下一个非空值替换任何空代理 ID 来提供正确的结果
| agent | id_agent | interaction_start_time | interaction_end_time | inbound_or_outbound | interaction_channel |
|---|---|---|---|---|---|
| 364920063 | 364920063 | 2020-09-16 6:38:47 | 2020-09-16 6:38:47 | Outbound | messaging |
| 364920063 | NULL | 2020-09-16 12:37:54 | 2020-09-16 12:37:54 | Inbound | messaging |
| 364920063 | 364920063 | 2020-09-17 8:02:07 | 2020-09-17 8:02:07 | Outbound | messaging |
| 191918955 | 191918955 | 2020-09-17 8:16:36 | 2020-09-17 8:25:45 | Outbound | messaging |
| 191918955 | NULL | 2020-09-17 11:16:47 | 2020-09-17 11:16:47 | Inbound | messaging |
| 191918955 | NULL | 2020-09-17 16:02:35 | 2020-09-17 16:11:30 | Inbound | messaging |
| 191918955 | 191918955 | 2020-09-20 2:13:14 | 2020-09-20 2:13:14 | Outbound | messaging |
| 191918955 | 191918955 | 2020-09-20 2:44:40 | 2020-09-20 2:46:09 | Inbound | messaging |
| 191918955 | 191918955 | 2020-09-20 7:13:40 | 2020-09-20 7:13:40 | Outbound | messaging |
【问题讨论】: