将csv数据加载到Hive表时出错 [英] Error loading csv data into Hive table
问题描述
我在hadoop中有一个csv文件,并且我有一个Hive表,现在我想将该csv文件放入此Hive表中。
我用LOAD DATA本地'path / to / csv / file'覆盖INTO TABLE表名;
结束了这个错误:
<$ p。$> $ $ c $> .verify.JDBC.result错误(r,无法检索JDBC结果集,:
无法检索LOAD DATA的JDBC结果集local
'path / to / csv / file'覆盖INTO TABLE tablename
(处理语句时出错:失败:
ParseException行1:16''path'/ tp csv / file'''处丢失INPATH'' ; EOF>'
)
注意:我正在使用RJDBC连接在r
我已经开发了一个工具来从csv文件生成配置单元脚本。 $ b工具 - https://sourceforge.net/projects/csvtohive/?source=directory
-
选择一个CSV文件使用浏览并设置hadoop根目录例如:/ user / bigdataproject /
-
工具生成包含所有csv文件的Hadoop脚本,以下是$ b的示例$ b生成Hadoop脚本以将csv插入到Hadoop中
#!/ bin / bash -v
hadoop fs -put ./AllstarFull.csv /user/bigdataproject/AllstarFull.csv
hive -f ./AllstarFull.hive
-
生成的Hive脚本示例
CREATE DATABASE IF NOT EXISTS lahman; <
USE lahman;
CREATE TABLE AllstarFull(playerID string,yearID string,gameNum string,game ID字符串,teamID字符串,lgID字符串,GP字符串,startingPos字符串)以','结尾的行格式定界字段存储为文本文件; -
LOAD DATA INPATH'/user/bigdataproject/AllstarFull.csv'OVERWRITE INTO TABLE AllstarFull;
SELECT * FROM AllstarFull;
hadoop fs -put ./Appearances.csv /user/bigdataproject/Appearances.csv
hive -f ./Appearances.hive
hadoop fs -put ./AwardsManagers.csv /user/bigdataproject/AwardsManagers.csv
hive -f ./AwardsManagers.hive
感谢
Vijay
i have a csv file in hadoop and i have a Hive table ,now i want to laoad that csv file into this Hive table
i have used load LOAD DATA local 'path/to/csv/file' overwrite INTO TABLE tablename;
ended up with this error :
Error in .verify.JDBC.result(r, "Unable to retrieve JDBC result set for ", :
Unable to retrieve JDBC result set for LOAD DATA local
'path/to/csv/file' overwrite INTO TABLE tablename
(Error while processing statement: FAILED:
ParseException line 1:16 missing INPATH at ''path/tp csv/file'' near '<EOF>'
)
Note: i am trying this using RJDBC connection in r
I have developed a tool to generate hive scripts from a csv file. Following are few examples on how files are generated. Tool -- https://sourceforge.net/projects/csvtohive/?source=directory
Select a CSV file using Browse and set hadoop root directory ex: /user/bigdataproject/
Tool Generates Hadoop script with all csv files and following is a sample of generated Hadoop script to insert csv into Hadoop
#!/bin/bash -v
hadoop fs -put ./AllstarFull.csv /user/bigdataproject/AllstarFull.csv hive -f ./AllstarFull.hive
hadoop fs -put ./Appearances.csv /user/bigdataproject/Appearances.csv hive -f ./Appearances.hive
hadoop fs -put ./AwardsManagers.csv /user/bigdataproject/AwardsManagers.csv hive -f ./AwardsManagers.hive
Sample of generated Hive scripts
CREATE DATABASE IF NOT EXISTS lahman;
USE lahman;
CREATE TABLE AllstarFull (playerID string,yearID string,gameNum string,gameID string,teamID string,lgID string,GP string,startingPos string) row format delimited fields terminated by ',' stored as textfile;
LOAD DATA INPATH '/user/bigdataproject/AllstarFull.csv' OVERWRITE INTO TABLE AllstarFull;
SELECT * FROM AllstarFull;
Thanks Vijay
这篇关于将csv数据加载到Hive表时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!