【发布时间】:2019-12-23 02:40:56
【问题描述】:
我有一些文本想一次分解为两个、三个甚至四个单词。我正在尝试提取有意义的短语。
我使用split 和explode 来检索我需要的内容,但我希望一次将行分成两个或三个单词。这是我目前所拥有的,一次只将行分成一个单词。
select explode(a.text) text
from (select split(text," ") text
from table abc
where id = 123
and date = 2019-08-16
) a
我得到的输出:
text
----
thank
you
for
calling
your
tv
is
not
working
?
我想要这样的输出:
text
----
Thank you
for calling
your tv
is not
working?
或类似的东西:
text
----
thank you for calling
your
tv is not working
?
【问题讨论】:
-
你必须为此定义你自己的 UDF 函数 - hive 不是那么聪明
-
请看这个答案:stackoverflow.com/a/52802766/2700344 - 分成 2 克