Redshift. Convert comma delimited values into rows

后端 未结 8 1186
北恋
北恋 2020-12-01 06:25

I am wondering how to convert comma-delimited values into rows in Redshift. I am afraid that my own solution isn\'t optimal. Please advise. I have table with one of the colu

8条回答
  •  生来不讨喜
    2020-12-01 06:51

    Another idea is to transform your CSV string into JSON first, followed by JSON extract, along the following lines:

    ... '["' || replace( user_action, '.', '", "' ) || '"]' AS replaced

    ... JSON_EXTRACT_ARRAY_ELEMENT_TEXT(replaced, numbers.i) AS parsed_action

    Where "numbers" is the table from the first answer. The advantage of this approach is the ability to use built-in JSON functionality.

提交回复
热议问题