【问题标题】:Hive - incomplete rows in select from managed partitioned tableHive - 从托管分区表中选择的不完整行
【发布时间】:2022-01-16 20:29:48
【问题描述】:

我需要将数据从 CSV 文件复制到 Hive 中的托管分区表。

CSV 文件行是:

id,nome,cognome,ruolo  
16,Mike,Maignan,Portiere    
23,Fikayo,Tomori,Centrale   
24,Simon,Kjaer,Centrale   
19,Theo,Hernandez,Terzino 
...

-------

我在ruolo 列上创建了一个托管分区表。

create table squadre_part 
(id int, nome string, cognome string) 
partitioned by (ruolo string)  
row format delimited fields terminated by ','  
stored as textfile  
TBLPROPERTIES ("skip.header.line.count"="1") ;  

-------

然后我创建了一个外部表来从 CSV 文件中加载数据(然后我将从外部表中选择数据并将它们复制到托管分区表中)

create external table external_squadre  
(id int, nome string, cognome string, ruolo string)    
row format delimited fields terminated by ','    
stored as textfile    
location '/ulisse/prove/external/'    
TBLPROPERTIES ("skip.header.line.count"="1")  ;

-------

首先我设置了这两个属性:

set hive.exec.dynamic.partition=true; 
set hive.exec.dynamic.partition.mode=nonstrict; 

--------

当我将 CSV 文件放入 /ulisse/prove/external/ HDFS 目录并从外部表执行选择时,我看到了所有行。

-------

从外部表“复制”到托管表之后:

insert into squadre_part partition (ruolo) select * from external_squadre;

我只看到托管表的几行 (???)。

奇怪的是,在 HDSF 下,/user/hive/warehouse/<mydb>/<managed table>/...

我看到所有子目录(以及子目录中的文本文件),以及原始 CSV 文件的所有行。

-------

命令:

msck repair table squadre_part 

(在插入命令之后...)没有解决问题。

提前感谢您的任何回复。

莫雷诺

【问题讨论】:

    标签: hive missing-data managed hive-partitions hiveddl


    【解决方案1】:

    有些行可能会丢失,因为您在托管表 DDL 中有 TBLPROPERTIES ("skip.header.line.count"="1"),实际上在 INSERT 期间没有创建任何标题。然后每个文件中的一行将丢失。如果文件很多,则会丢失很多行。从托管表中删除该属性。

    如果您使用 LOAD 命令加载带有标题的文件或直接将带有标题的文件放入表位置,请使用 skip.header.line.count 属性。

    【讨论】:

    • 谢谢!如果托管表中没有skip.header.line.count,所有行都会被选中。
    猜你喜欢
    • 2015-09-13
    • 2022-07-29
    • 1970-01-01
    • 1970-01-01
    • 2022-10-17
    • 1970-01-01
    • 2021-06-22
    • 2019-06-18
    • 1970-01-01
    相关资源
    最近更新 更多