gpt4 book ai didi

hadoop - 在配置单元中过滤

转载 作者:可可西里 更新时间:2023-11-01 15:26:37 26 4
gpt4 key购买 nike

我有一个配置单元表演示(id bigint,项目字符串),其中数据集是一组逗号分隔的字符串,如

id  dataset 
1 ,2,asd,as,a,1
2 sda,saa,2,fds

有没有一种 native 方法可以过滤掉非数字字符串并仅保留数字字符串,而不是分解表、过滤然后分组或编写我自己的 UDF。

id  dataset 
1 2,1
2 2

最佳答案

select  id
,regexp_replace(regexp_replace(dataset,'(?<=^|,)((\\d+)|([^,]*))(?=,|$)','$2'),'^,+|,+$|(,)+','$1')

from demo
;

+----+-----+
| id | c1 |
+----+-----+
| 1 | 2,1 |
| 2 | 2 |
+----+-----+

关于hadoop - 在配置单元中过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45065244/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com