也就是说大家以后不必再用“select count(*) from user ”去查询user表的大小了,因为HIVE会将这个语句翻译为MR作业在HADOOP上运行,效率非常低。
新的方法是
HiveConf
conf = new HiveConf(SessionState.class); Hive
hive = Hive.get(conf); System.out.println(hive.getTable("user").getTTable() .getParameters()); List
list = hive.getPartitions(hive.getTable("user")); for
(Partition p : list) { System.out.println(p.getParameters()); }
其中打印出来的就是USER表的元数据。
PS:
1。有人会问
select count(1) from user where age=20 这种带有条件的计数怎么办?