1、传统方式获得总条数例如以下:
select count(*) from ods.tracklog;
2、通过元数据获取方式如下:
查库
查询不含分区表的总条数 select FORMAT(sum(tb.PARAM_VALUE),0) from TBLS t left join DBS d on t.DB_ID = d.DB_ID left join TABLE_PARAMS tb on t.TBL_ID = tb.TBL_ID where d.NAME='hive_ods' and tb.PARAM_KEY='numRows'; 查询含有分区表的总条数 select FORMAT(sum(a.PARAM_VALUE),0) from TBLS t left join DBS d on t.DB_ID = d.DB_ID left join PARTITIONS p on t.TBL_ID = p.TBL_ID left join PARTITION_PARAMS a on p.PART_ID=a.PART_ID where d.NAME='hive_ods_partition' and a.PARAM_KEY='numRows';
查表
select d.NAME,t.TBL_NAME,t.TBL_ID,p.PART_ID,p.PART_NAME,a.PARAM_VALUE from TBLS t left join DBS d on t.DB_ID = d.DB_ID left join PARTITIONS p on t.TBL_ID = p.TBL_ID left join PARTITION_PARAMS a on p.PART_ID=a.PART_ID where t.TBL_NAME='tracklog' and d.NAME='ods' and a.PARAM_KEY='numRows'; select FORMAT(sum(a.PARAM_VALUE),0) from TBLS t left join DBS d on t.DB_ID = d.DB_ID left join PARTITIONS p on t.TBL_ID = p.TBL_ID left join PARTITION_PARAMS a on p.PART_ID=a.PART_ID where t.TBL_NAME='tracklog' and d.NAME='ods' and a.PARAM_KEY='numRows';



