Comma delimited string to individual rows - Impala SQL

北慕城南 提交于 2019-12-10 21:26:08

问题


Let's suppose we have a table:

Owner   | Pets
------------------------------
Jack    | "dog, cat, crocodile" 
Mary    | "bear, pig"

I want to get as a result:

Owner   | Pets
------------------------------
Jack    | "dog"
Jack    | "cat"
Jack    | "crocodile" 
Mary    | "bear"
Mary    | "pig"

I found some solutions to similar problems by googling, but Impala SQL does not offer any of these capabilities to apply the suggested solutions.

Any help would be greatly appreciated!


回答1:


The following works in Impala:

split_part(string source, string delimiter, bigint n)

You can find the documentation here:

https://www.cloudera.com/documentation/enterprise/5-9-x/topics/impala_string_functions.html



来源:https://stackoverflow.com/questions/37399187/comma-delimited-string-to-individual-rows-impala-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!