我有一个数据集,其中有一列带有一组时间戳,一列只有一个时间戳。我正在寻找使用 c1 时间戳作为更大和更小的条件来获取数组的大小。
表(my_table):
c1 | c2 |
----------------------------|
4 | [1,2,3,4,5,6,7,8,9,10] |
1 | [1,2,3,4,5,6,7,8,9,10] |
5 | [1,2,3,4,5,6,7,8,9,10] |
3 | [1,2,3,4,5,6,7,8,9,10] |
询问:
select
c1,
c2,
size(some_udf_split_on_c1(sort_array(<array>), c1)[1]) AS smaller_than_c1
size(some_udf_split_on_c1(sort_array(<array>), c1)[2]) AS larger_than_c1
from my_table
udf 是我假设的实现。
输出:
c1 | c2 | smaller_than_c1 | larger_than_c1
----------------------------|-----------------|---------------
4 | [1,2,3,4,5,6,7,8,9,10] | 3 | 6
1 | [1,2,3,4,5,6,7,8,9,10] | 0 | 9
5 | [1,2,3,4,5,6,7,8,9,10] | 4 | 5
3 | [1,2,3,4,5,6,7,8,9,10] | 1 | 8