HiveQL中受影响的行数

时间:2014-12-12 23:06:25

标签: hadoop hive hiveql cloudera-cdh

有没有办法在hive中运行CTAS后获得受影响的行数?

我正在运行

从t2创建表t1 as select *,其中......;

基本上,我想打印新表中的行数以便记录。

谢谢!

1 个答案:

答案 0 :(得分:0)

Hive会报告作为CTAS一部分受影响的行数:请参见此处的示例:

Table default.errors2 stats: [num_partitions: 0, num_files: 1, num_rows: 860, total_size: 17752, raw_data_size: 16892]

输出的更多细节:

hive> create table errors2 as select * from errors;
..
Stage-5 is filtered out by condition resolver.
Moving data to: hdfs://localhost:9000/tmp/hive-steve/hive_2014-12-13_06-00-40_553_7396982929134959624/-ext-10001
Moving data to: hdfs://localhost:9000/user/hive/warehouse/errors2
Table default.errors2 stats: [num_partitions: 0, num_files: 1, num_rows: 860, total_size: 17752, raw_data_size: 16892]
OK
dayandhour  dowandhour  cnt
Time taken: 7.348 seconds

更新 OP询问是否在变量中保存rowcount。没有内置的蜂巢命令AFAIK。但是,您可以通过命令行从

运行命令
hive -e "<hivesql>"  | grep "[num_partitions]" | <regex command to isolate the num_rows>