我想将.csv
文件作为ORC文件加载到Hive表中。我遇到了一个post
这提出了我执行以下查询的问题的解决方法:
1)创建数据并将其作为文本文件加载到临时表中:
CREATE TABLE IF NOT EXISTS CrimesData( ID int, Case_Number int, CrimeDate string, Block string , IUCR string,Primary_Type string, Description string, Location_Description string, Arrest string, Domestic string, Beat int, District int, Ward int, Community_Area int, FBI_Code string, X_Coordinate int, Y_Coordinate int, Year int, Updated_On string, Latitude decimal(10,10), Longitude decimal(10,10), CrimeLocation string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n'
tblproperties("skip.header.line.count"="1")
LOAD DATA LOCAL INPATH '/home/cloudera/Documents/CrimesData.csv' INTO TABLE CrimesData
2)创建新表并将ORC数据指定为源:
CREATE TABLE IF NOT EXISTS CrimesDataORC( ID int, Case_Number int, CrimeDate string, Block string , IUCR string,Primary_Type string, Description string, Location_Description string, Arrest string, Domestic string, Beat int, District int, Ward int, Community_Area int, FBI_Code string, X_Coordinate int, Y_Coordinate int, Year int, Updated_On string, Latitude decimal(10,10), Longitude decimal(10,10), CrimeLocation string)
STORED AS ORC;
3)从临时表中将数据插入新表:
INSERT INTO TABLE CrimesDataORC SELECT * FROM CrimesData;
前两个步骤执行时没有任何错误,但步骤3抛出以下错误:
处理语句时出错:FAILED:执行错误,返回代码 2来自org.apache.hadoop.hive.ql.exec.mr.MapRedTask
我在Cloudera Manager Quickstart VM 5.8上运行上述查询。
不确定我哪里出错了,因为同一数据库中另一个表的类似步骤按预期工作。
答案 0 :(得分:0)
可能是某种数据不符合结构。尝试在select语句中设置一些条件来检查而不是插入所有数据