gpt4 book ai didi

hadoop - 创建一个 HIVE 表并将其保存到一个制表符分隔的文件中?

转载 作者:可可西里 更新时间:2023-11-01 16:39:19 25 4
gpt4 key购买 nike

我在hdfs中有一些数据。
此数据是使用 Sqoop 从 PostgreSQL 数据库迁移而来的。
数据具有以下 hadoopish 格式,如 _SUCCESSpart-m-00000 等。
我需要基于此数据创建一个 Hive 表,然后我需要将此表导出到一个制表符分隔的文件。

据我所知,我可以通过这种方式创建表格。

create external table table_name (
id int,
myfields string
)
location '/my/location/in/hdfs';

然后我可以将表格保存为 tsv 文件:

hive -e 'select * from some_table' > /home/myfile.tsv

我不知道如何将数据从 hdfs 加载到 Hive 表中。
此外,我应该使用 create 手动定义表的结构,还是自动创建所有列时是否有任何自动化方法?

最佳答案

I don't know how to load data from hdfs into Hive table

您可以像现在一样在 hdfs 目录上创建一个表架构。

should I manually define the structure of a table using create or is there any automated way when all columns are created automatically?

除非你没有tell sqoop to create the table ,您必须手动执行。

export this table into a single tab-separated file.

查询可能有效,或者除非 sqoop 将分隔符设置为 \t,否则您需要从第一个指定此类列分隔符的表开始创建另一个表。然后,您甚至不需要查询表,只需在目录上运行 hdfs dfs -getMerge

关于hadoop - 创建一个 HIVE 表并将其保存到一个制表符分隔的文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44847142/

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