dolphinscheduler 调度 DataX 记录

hive库默认的存储格式是 orc 格式 ,使用datax将mysql的数据导出到hdfs上时候,遇到hive无法读取的问题.

#hive提供了一个--orcfiledump参数用于查看HDFS上ORC表格的文件信息
hive --orcfiledump
#解析 orc 格式 为 json 格式 写入到文件
hive --orcfiledump -d  hdfs的orc文件路径 > myfile.txt

创建表1 表2 表3 测试

#ds_test  
orc 无压缩

hive --orcfiledump  /warehouse/tablespace/managed/hive/test.db/ds_test/ds_test__b9f4a3f0_2dce_42c2_95c2_b1143b222187


Structure for /warehouse/tablespace/managed/hive/test.db/ds_test/ds_test__b9f4a3f0_2dce_42c2_95c2_b1143b222187
File Version: 0.12 with HIVE_8732
Rows: 2
Compression: ZLIB
Compression size: 262144
Type: struct<uid:double,id:int,name:string>



查表报错


/warehouse/tablespace/managed/hive/test.db/ds_test/ds_test__5cc20379_2609_4d92_ab69_8f8807f5681c

Structure for /warehouse/tablespace/managed/hive/test.db/ds_test3/ds_test3_0000
File Version: 0.12 with HIVE_8732
Rows: 2
Compression: ZLIB
Compression size: 262144
Type: struct<uid:double,id:int,name:string>


#ds_test2
text 无压缩


查表正常


#ds_test3
orc格式 'orc.compress'='ZLIB'压缩
hive --orcfiledump /warehouse/tablespace/managed/hive/test.db/ds_test3/delta_0000002_0000002_0000

File Version: 0.12 with ORC_135
Rows: 2
Compression: ZLIB
Compression size: 32768
Type: struct<operation:int,originalTransaction:bigint,bucket:int,rowId:bigint,currentTransaction:bigint,row:struct<uid:double,id:int,name:string>>


查表报错



--datax导出来的文件 转成json之后 里面内容正确 

{"uid":12.68,"id":1,"name":"zjq"}
{"uid":16.36,"id":2,"name":"qjz"}

测试结果:

#datax输出到的hdfs文件 
#参数compress为空
 hive --orcfiledump  /warehouse/tablespace/managed/hive/test.db/ds_test/no_com__130b1a05_08cd_42e0_9d1e_828797dc8a3a
File Version: 0.12 with HIVE_8732
Rows: 2
Compression: ZLIB
Compression size: 262144
 hive --orcfiledump  /warehouse/tablespace/managed/hive/test.db/ds_test/ds_test__718edfce_5b98_4e5c_b5d4_d70961bc3958
#参数compress为NONE
File Version: 0.12 with HIVE_8732
Rows: 2
Compression: ZLIB
Compression size: 262144

测试发现 默认使用的是zlib压缩 并不是官网文档上写的 "默认不填写意味着没有压缩" 



目前datax 只能输出为text文件到hdfs上才能在hive上直接查询 因为hive在load数据时是只支持load text格式的文件的
是符合数仓ods层原始数据的规则 上层沉淀之后ods层数据的压缩存储交给用户来做 
posted @ 2021-12-28 16:08  超级无敌小剑  阅读(770)  评论(0编辑  收藏  举报