列式存儲以orc和parquet文件居多,現(xiàn)階段hive數(shù)據(jù)存儲的主流格式是orc,然后結合presto(目前對orc的支持好于parquet)做一些即席查詢。hive數(shù)據(jù)文件是直接存儲在hdfs上,但是hadoop貌似沒有提供直接查看文本的命令,好在hive提供了支持。
一、ORC文件查看
1. 命令幫助: hive --service orcfiledump --help
$ hive --service orcfiledump --help
usage ./hive orcfiledump [-h] [-j] [-p] [-t] [-d] [-r <col_ids>] [--recover] [--skip-dump] [--backup-path <new-path>] <path_to_orc_file_or_directory>
--json (-j) Print metadata in JSON format
--pretty (-p) Pretty print json metadata output
--timezone (-t) Print writer's time zone
--data (-d) Should the data be printed
--rowindex (-r) <col_ids> Comma separated list of column ids for which row index should be printed
--recover Recover corrupted orc files generated by streaming
--skip-dump Used along with --recover to directly recover files without dumping
--backup-path <new_path> Specify a backup path to store the corrupted files (default: /tmp)
--help (-h) Print help message
# (-[a-z])里的內容為縮寫,與前面的--xx等價,使用起來更加方便
# --json --pretty都用于metadata信息的展示,后者對輸出的json進行了格式化
# --data 可用于數(shù)據(jù)預覽
2. 數(shù)據(jù)預覽演示
hive --service orcfiledump -d /warehouse/tablespace/managed/hive/ads.db/xxx/dw=2021-07-05 | tail
① 建議挑選較小的文件進行測試
②文件實在很大建議使用tail,使用head在輸出指定的行數(shù)后會報一堆的異常信息
二、ORC文件修復
今天使用presto查hive數(shù)據(jù)的時候報了如下異常Query 20230313_083619_19104_9jvmr failed: Failed to read ORC file: hdfs://DATALAKE/warehouse/tablespace/managed/hive/dim.db/xxx/dw=2023-03-06/000065_0
但是從hdfs上看文件是存在的,也有大小,然后嘗試了下修復命令
hive --service orcfiledump --recover /warehouse/tablespace/managed/hive/dim.db/xxx/dw=2023-03-06/000065_0
修復成功
文章來源:http://www.zghlxwxcb.cn/news/detail-567007.html
(建議先備份文件)
暫未發(fā)現(xiàn)異常,大家如有遇到orc fail這種情況可以嘗試下文章來源地址http://www.zghlxwxcb.cn/news/detail-567007.html
到了這里,關于使用hive查看orc文件 orcfiledump命令詳解 異常處理(Failed to read ORC file)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!