逗号分隔字符串到单个行 - Impala SQL

时间:2021-12-31 16:28:48

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.

我通过谷歌搜索找到了类似问题的一些解决方案,但Impala SQL没有提供任何这些功能来应用建议的解决方案。

Any help would be greatly appreciated!

任何帮助将不胜感激!

1 个解决方案

#1


2  

The following works in Impala:

以下适用于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://www.cloudera.com/documentation/enterprise/5-9-x/topics/impala_string_functions.html

#1


2  

The following works in Impala:

以下适用于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://www.cloudera.com/documentation/enterprise/5-9-x/topics/impala_string_functions.html