gpt4 book ai didi

hadoop - Hive - 使用不包括行终止符的文本文件创建外部表

转载 作者:可可西里 更新时间:2023-11-01 14:51:43 26 4
gpt4 key购买 nike

我想用一组文本文件创建一个外部表。每行应该是一个文本文件。一个文本文件的示例如下,可以有多个文本文件。(文件存储在HDFS中)

thanking 
you
for
the
participation

行由 /n 终止。我想用上面的文本文件创建一个外部表,文本文件中的数据应该在一行(一个单元格)中。

我尝试了以下创建表语句。

Create External table if not exists sample_email(
email STRING
)
STORED AS TEXTFILE
LOCATION '/tmp/txt/sample/';

它会给出创建表如下。

+--------------------------------------+
+ email +
+--------------------------------------+
+ thanking +
+--------------------------------------+
+ you +
+--------------------------------------+
+ for +
+--------------------------------------+
+ the +
+--------------------------------------+
+participation +
+--------------------------------------+
+please +
+--------------------------------------+
+find +
+--------------------------------------+
+the +
+--------------------------------------+
+discussed +
+--------------------------------------+
+points +
+--------------------------------------+

但我想要如下。

+--------------------------------------+
+ email +
+--------------------------------------+
+ thanking you for the participation +
+--------------------------------------+
+ please find the discussed points +
+--------------------------------------+

如何解决我的问题?提前谢谢你

最佳答案

select      concat_ws(' ',collect_list(email))  as emails
from sample_email
group by input__file__name

+------------------------------------+
| emails |
+------------------------------------+
| thanking you for the participation |
| please find the discussed points |
+------------------------------------+

关于hadoop - Hive - 使用不包括行终止符的文本文件创建外部表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42975761/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com