hive中的虚拟列

hive为用户提供了三个虚拟列:用户可以通过这三个虚拟列确定记录是来自哪个文件以及这条记录的具体位置信息

INPUT__FILE__NAME

返回记录所在的具体hdfs文件全路径

hive> select sys_tra_no,INPUT__FILE__NAME from testcom_rcfile limit 1;
OK
350356  hdfs://nameservice1/user/dw_hbkal/db/test_tooldb/testcom_rcfile/ins_id_cd=01020000/hp_settle_dt=20180710/000000_0

BLOCK__OFFSET__INSIDE__FILE

如果是RCFile或者是SequenceFile块压缩格式文件,则显示Block file Offset,也就是当前块在所在文件的第一个字偏移量(一个块包涵多条记录),如果是TextFile,显示当前行的第一个字节在文件中的偏移量

hive> select sys_tra_no,BLOCK__OFFSET__INSIDE__FILE from testcom_rcfile limit 2;
350356  57
217440  57
hive> select sys_tra_no,BLOCK__OFFSET__INSIDE__FILE from testcom limit 2;
350356  0
217440  301

ROW__OFFSET__INSIDE__BLOCK

如果是RCFile和SequenceFile,显示记录在所在块中的行号;如果是TextFile,则无意义,全为0

set hive.exec.rowoffset=true;
hive> select sys_tra_no ,ROW__OFFSET__INSIDE__BLOCK from testcom_rcfile limit 2;
350356  0
217440  1
hive> select sys_tra_no ,ROW__OFFSET__INSIDE__BLOCK from testcom limit 2;
350356  0
217440  0
原文地址:https://www.cnblogs.com/darange/p/13531879.html