2017-08-01 139 views
0

我安裝了單個節點Cloudera以開始瞭解這些技術。現在,我試圖從CSV文件創建HUE表。使用HUE創建Hive表

當我嘗試做這件事,正在創建的表,但沒有任何數據,只是列結構,我得到了以下錯誤:

Error while compiling statement: FAILED: SemanticException Line 1:17 Invalid path ''/user/josholsan/ic_data/_glucosa.csv'': No files matching path hdfs://server_name:8020/user/josholsan/ic_data/_glucosa.csv

錯誤說沒有匹配此文件路徑,但是當我嘗試在終端下面,該文件是正確的有:

hadoop fs -ls hdfs//server_name.8020/user/josholsan/ic_data/_glucosa.csv 

代碼HUE正在執行創建表是以下之一:

CREATE TABLE `test`.`cpk` 
(
    `id` bigint , 
    `numsipcod` string , 
    `valor` bigint , 
    `fecharegistro` string) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde' 
    WITH SERDEPROPERTIES ("separatorChar" = "\t", 
    "quoteChar"  = "\"", 
    "escapeChar" = "\\" 
) 
    STORED AS TextFile TBLPROPERTIES("skip.header.line.count" = "1") 
; 

LOAD DATA INPATH '/user/josholsan/ic_data/_glucosa.csv' INTO TABLE `test`.`glucosa`; 

我也嘗試從本地使用LOAD DATA LOCAL INPATH加載文件。

我實際上並不知道如何繼續。我一直在檢查互聯網,但我發現沒有幫助我。 有,關於我的注意力叫什麼,是該文件的權限,當我寫這上面行命令,權限是: - RW-R - R--

不管怎麼說,我禁用了權限檢查HDFS設置。

任何有HDFS/HUE/Cloudera知識的人都知道這裏可能存在哪些問題? 感謝你這麼多提前=)

+1

蜂巢需要一個** **目錄作爲'LOCATION',而不是文件。帶領頭或下劃線的文件通常是由設計_ignored_設計的信號量或臨時文件... –

+0

非常感謝你@SamsonScharfrichter。重新命名文件與領先_解決了問題。關於目錄LOCATION,你怎麼指定你想要加載到表中的文件?它對我沒有任何作用。再次感謝你。你能把它作爲解決方案發布嗎? –

回答

1

TL;DR    重命名文件 - 中的Hadoop生態系統中,數據文件的名字開始與一個圓點或下劃線是通常被忽略,被設計。

which files ignored as input by mapper?

(... Hadoop source code excerpt...)

So if you use ... TextInputFormat ... the hidden files (the file name starts with "_" or ".") will be ignored.

蜂房TextFile格式依賴於MapReduce的TextInputFormat - 因此所有帶有前導點或下劃線開頭被忽略的文件;它們應該是信號量(例如Pig或Spark使用的_SUCCESS)或臨時目錄(例如.impala_insert_staging/)等。

此外,從the Impala documentation的摘錄:

The INSERT statement has always left behind a hidden work directory inside the data directory of the table. Formerly, this hidden work directory was named .impala_insert_staging . In Impala 2.0.1 and later, this directory name is changed to _impala_insert_staging .
(While HDFS tools are expected to treat names beginning either with underscore and dot as hidden, in practice names beginning with an underscore are more widely supported.)