Presto 拆分字符串,但输出到新行

Presto split string, but output to a new line

抱歉,如果问题含糊不清。

我有一个字符串,我想以某种方式格式化

Currently it gets outputted like this

Could I output this like this? 在每个分隔符之后换行?

常用的分隔符是竖线 (|)。

您可以结合使用 split() function to turn the strings into arrays of elements, and UNNEST,将数组中的每个元素转换为单独的行:

WITH t(column, text) AS (
    VALUES
        ('column1', 'text1|text2|text3'),
        ('column2', 'text3|text4|text4')
)
SELECT t.column, u.item
FROM t, UNNEST(split(t.text, '|')) u(item)