2013-12-17 55 views
0

我在hive中創建表並且也從hdfs加載csv文件,但是當嘗試在創建的表上執行select查詢時,我以加密格式獲得結果,請您爲此提供解決方案。如何在配置表格中加載csv文件?

create table if not exists studentsinforamtion(
    studentnumber string , 
    universityname string, 
    collegename string, 
    studentname string, 
    branch string, 
    percentage string, 
    areaters string, 
    rankatuniversity INT, 
    eligibleforcompnay string, 
    selectedcompanylist int) 
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' 
stored as textfile; 

load data inpath '/user/root/jobportal/studentinfo.ods' overwrite into table studentsinforamtion; 

select * from studentsinforamtion limit 5; 

錯誤:

OK 
PK5:�C�l9�.mimetypeapplication/vnd.oasis.opendocument.spreadsheetPK5:�C�{C44meta.xml<?xml version="1.0" encoding="UTF-8"?> NULL NULL NULL NULL NULL NULL NULL NULL NULL 
<office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:grddl="http://www.w3.org/2 
+0

這可能很有用:http://chase-seibert.github.io/blog/2013/05/17/hive-insert-and-dump-csv-with-map-datatype.html – Ranveer

+0

a csv-serde在處理csv文件時很好,因爲通常一個字段可能包含使定義的serde不可用的分隔符char – selle

回答

0

看起來你的文件不是純粹的以逗號分隔的文件(或製表符分隔,因爲我從你的表的分隔符見)。它有一些opentocument元數據「mimetypeapplication/vnd.oasis.opendocument.spreadsheetPK5: C {C44meta.xml」。嘗試以.csv格式保存文檔,或使用簡單的文本編輯器創建所需的電子表格。如果在選擇結果中'NULL'通常意味着列類型和值類型不同 - 例如,列類型和值類型是不同的。你有列類型(int,int,int)的表格,並且你已經用值(15,23,userinfo)下載了文件 - 選擇應該返回15,23,NULL。 Hive在上傳過程中不檢查值的類型,因此請注意它們。