繁体   English   中英

Hive:SELECT * 语句有效,但 SELECT COUNT(*)

[英]Hive: SELECT * statement works but not SELECT COUNT(*)

我在 Windows Server 2008 R2 上有 HDP 1.1。
我将 Web 登录加载到 hive 表中。 创建表语句:

create table logtable (datenonQuery string , hours string, minutes string, seconds string, TimeTaken string, Method string, UriQuery string, ProtocolStatus string) row format serde 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe' with serdeproperties( "input.regex" = "(\\S+)\\t(\\d+):(\\d+):(\\d+)\\t(\\S+)\\t(\\S+)\\t(\\S+)\\t(\\S+)", "output.format.string" = "%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s") stored as textfile; 

负载声明:

load data local inpath 'D:\Logfiles\' into table logtable;

选择声明:

Select * from logtable;

到目前为止一切正常。

以下语句失败:

Select count(*) from logtable;

除了:

失败:执行错误,从 org.apache.hadoop.hive.ql.exec.MapRedTask 返回代码 2

编辑1:

失败作业表中的诊断信息显示以下信息:

'失败的地图任务的数量超过了允许的限制。 FailedCount: 1. LastFailedTask: task_201306251711_0010_m_000000'

这与其说是 hive,不如说是一个与 hadoop 相关的东西。 SELECT * 有效而 SELECT COUNT(*) 无效的原因是后者涉及 MR 工作。 你的数据大小是多少?

尝试通过将属性mapred.job.map.memory.mb设置为更高的值来增加映射器堆大小。 还可以尝试通过通过mapred.min.split.size降低拆分大小来增加映射器的数量,看看它是否有任何区别。

如果输出结果集有 2 列同名(可能在 hive/impala 中),则 count(*) 将不起作用。

例如,查询#1 会给出结果,而查询#2 会给出错误。

解决方案 - 别名 product_code 列将解决查询 #2 中的错误

1)选择a.product_code, b.product_code, b.product_name, a.purchase_date, a.purchase_qty from product_fact ainner join product_dim b on (a.product_code = b.product_code)

2) Select * from ( Select a.product_code, b.product_code, b.product_name, a.purchase_date, a.purchase_qty from product_fact ainner join product_dim b on (a.product_code = b.product_code) ) as C

对我来说,这个特定的错误是一个访问问题。 当我使用用户名和密码连接到数据库时它已解决

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM