簡體   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