我正在尝试使用 arrayJoin() 拆分 2 个数组
我的桌子:
create table test_array(
col1 Array(INT),
col2 Array(INT),
col3 String
)
engine = TinyLog;
Run Code Online (Sandbox Code Playgroud)
然后我插入这些值:
insert into test_array values ([1,2],[11,22],'Text');
insert into test_array values ([5,6],[55,66],'Text');
Run Code Online (Sandbox Code Playgroud)
当我拆分 col1 中的第一个数组时,结果将如下所示:
但我需要的是拆分 col1 和 col2 并将它们添加到选择中。
我尝试了这个查询,但没有成功。
select arrayJoin(col1) ,arrayJoin(col2) ,col1 , col2 ,col3 from test_array;
Run Code Online (Sandbox Code Playgroud)
如何编辑查询以删除图片中突出显示的行?
谢谢。
arrayJoin的串行调用会产生笛卡尔积,为了避免它使用ARRAY JOIN:
\nSELECT\n c1,\n c2,\n col1,\n col2,\n col3\nFROM test_array\nARRAY JOIN\n col1 AS c1,\n col2 AS c2\n\n/*\n\xe2\x94\x8c\xe2\x94\x80c1\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80c2\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80col1\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80col2\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80col3\xe2\x94\x80\xe2\x94\x90\n\xe2\x94\x82 1 \xe2\x94\x82 11 \xe2\x94\x82 [1,2] \xe2\x94\x82 [11,22] \xe2\x94\x82 Text \xe2\x94\x82\n\xe2\x94\x82 2 \xe2\x94\x82 22 \xe2\x94\x82 [1,2] \xe2\x94\x82 [11,22] \xe2\x94\x82 Text \xe2\x94\x82\n\xe2\x94\x82 5 \xe2\x94\x82 55 \xe2\x94\x82 [5,6] \xe2\x94\x82 [55,66] \xe2\x94\x82 Text \xe2\x94\x82\n\xe2\x94\x82 6 \xe2\x94\x82 66 \xe2\x94\x82 [5,6] \xe2\x94\x82 [55,66] \xe2\x94\x82 Text \xe2\x94\x82\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xb4\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xb4\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xb4\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xb4\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\n*/\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
6738 次 |
| 最近记录: |