gpt4 book ai didi

hive - 将本地 csv 文件直接加载到 hive parquet 表,而不是求助于临时文本文件表

转载 作者:行者123 更新时间:2023-12-01 13:40:57 27 4
gpt4 key购买 nike

我现在准备将 .csv 文件中的数据存储到 hive 中。当然,由于parquet文件格式性能好,hive表应该是parquet格式。因此,通常的方法是创建一个格式为 textfile 的临时表。 ,然后我将本地 CSV 文件数据加载到这个临时表中,最后,创建一个相同结构的 Parquet 表并使用 sql insert into parquet_table values (select * from textfile_table); .

但我不认为这个临时文本文件表是必要的。所以,我的问题是,有没有办法让我将这些本地 .csv 文件直接加载到 hive parquet-format 表中,即不使用临时表?或者更简单的方法来完成这项任务?

最佳答案

Hive documentation 中所述:

NO verification of data against the schema is performed by the load command.

If the file is in hdfs, it is moved into the Hive-controlled file system namespace.


您可以使用 CREATE TABLE AS SELECT 跳过一个步骤为 Parquet 。
因此,您将有 3 个步骤:
  • 创建定义架构的文本表
  • 将数据加载到文本表中(将文件移动到新表中)
  • CREATE TABLE parquet_table AS SELECT * FROM textfile_table STORED AS PARQUET; supported from hive 0.13
  • 关于hive - 将本地 csv 文件直接加载到 hive parquet 表,而不是求助于临时文本文件表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40337340/

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