sql - Trino 实现了类似 regexp_split_to_table() 的函数?
问题描述
每个人,
我是 Trino 的新手,我发现 Trinoregexp_split_to_table()
中没有像 GreenPlum 或 PostgreSQL 那样的功能。我该如何处理?
select regexp_split_to_table( sensor_type, E',+' ) as type from hydrology.device_info;
解决方案
有regexp_split(string, pattern)函数,返回数组,可以取消嵌套。
演示:
select s.str as original_str, u.str as exploded_value
from
(select 'one,two,,,three' as str)s
cross join unnest(regexp_split(s.str,',+')) as u(str)
结果:
original_str exploded_value
one,two,,,three one
one,two,,,three two
one,two,,,three three
推荐阅读
- android - 是否有针对 BottomSheetBehavior 状态的 Espresso 检查?
- javascript - 如何使此 HTML 按钮居中并确保其位置不变?
- python - 如何告诉 python pandas 条形图从 x 标签值中选择颜色?
- arrays - 根据相应索引从嵌套数组创建新数组
- rust - 如何在同一个 crate 中使用 Rust 宏?
- laravel - Laravel 获取父属性
- django - 如何模拟 Queryset 切片运算符
- file - 如何执行 .bat 文件,Robot Framework
- sql - 是否有允许我将查询结果自动导出到 .csv 的 SQL 函数?
- php - 尝试返回数据 URL PHP 时遇到的非数字值