查询错误 - 发现重复的别名偏移量

问题描述 投票:0回答:1

我正在尝试使用以下逻辑来获得预期的输出,但在我的问题中提到了错误,

我正在尝试基于逗号分隔符取消嵌套多个列,并在取消嵌套并进行联接以避免重复时避免重复。当我用偏移连接 2 列时,我没有看到任何问题,但是当处理超过 2 列时,会遇到错误。

select Colm_A, Colm_B, Colm_C
from your_table, 
unnest(split(Colm_B)) Colm_B with offset
join unnest(split(Colm_C)) Colm_C with offset join unnest(split(Colm_D)) Colm_D
using (offset);

来源表

Colm_A  Colm_B  Colm_C COL_D
1       Fish     F      H
2       Dog,cat  D,C    G,T

预期产量

Colm_A  Colm_B  Colm_C  COLM_D
1       Fish    F        H
2        Dog    D        G
2        Cat    C        T
google-bigquery unnest
1个回答
0
投票

使用下面

select Colm_A, Colm_B, Colm_C, Colm_D
from your_table, 
unnest(split(Colm_B)) Colm_B with offset as B
join unnest(split(Colm_C)) Colm_C with offset as C on B = C
join unnest(split(Colm_D)) Colm_D with offset as D on B = D

有输出

© www.soinside.com 2019 - 2024. All rights reserved.