Flink 如何取消多个数组列的嵌套,同时保留数组的顺序

xpcnnkqh  于 2022-12-09  发布在  Apache
关注(0)|答案(1)|浏览(137)

What is the SQL statement to unnest both columns containing arrays while preserving the array order?
| col1 | col2 |
| ------------ | ------------ |
| [1,2,3,4] | [1,2,3,4] |
Expected Result
| col1 | col2 |
| ------------ | ------------ |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |

oknrviil

oknrviil1#

像这样使用CROSS APPLY STRING_SPLIT函数

select * from (
select value as Col1 from test
CROSS APPLY STRING_SPLIT(replace(replace(Col1,'[',''),']',''),',') 
)a
left join (
select value as Col2 from test
CROSS APPLY STRING_SPLIT(replace(replace(Col2,'[',''),']',''),',') 
)b on a.col1 =b.col2

enter link description here

相关问题