【问题标题】:Unable to load text data into Hive table as ORC through temporary Hive table无法通过临时 Hive 表将文本数据作为 ORC 加载到 Hive 表中
【发布时间】:2023-03-19 13:26:01
【问题描述】:

我想将.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;

前两步执行没有任何错误,但第三步抛出以下错误:

处理语句时出错:FAILED:执行错误,返回码 2 来自 org.apache.hadoop.hive.ql.exec.mr.MapRedTask

我在 Cloudera Manager Quickstart VM 5.8 上运行上述查询。

不确定我哪里出错了,因为同一数据库中另一个表的类似步骤按预期工作。

【问题讨论】:

    标签: hadoop hive cloudera-manager orc cloudera-quickstart-vm


    【解决方案1】:

    这可能是一种不符合结构的数据。尝试在select语句中设置一些where条件来检查而不是插入所有数据

    【讨论】:

    • 感谢您的建议,我会尝试并更新是否有效.. ?
    • 尝试执行:INSERT INTO TABLE CrimesDataORC SELECT * FROM CrimesData LIMIT 10;但这也没有成功.. :(
    猜你喜欢
    • 1970-01-01
    • 2015-12-01
    • 2015-12-28
    • 2014-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-23
    相关资源
    最近更新 更多