gpt4 book ai didi

hadoop - 无法在 Hive 上对表进行分区 - 元数据错误

转载 作者:可可西里 更新时间:2023-11-01 16:49:25 26 4
gpt4 key购买 nike

我在 Hive 中创建了一个表,其中加载了数据。

我想根据 Column spec: DoJ 对其进行分区,其中值为 2012

我用过:

ALTER TABLE employee
ADD PARTITION (year='2012')
location '/home/rvarun/2012/part2012';

我收到错误:

FAILED: Error in metadata: table is not partitioned but partition spec exists: {year=2012}
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

我是 Hive 的新手,所以请原谅我的任何新手。

我的表是这样的:

1001    Varun   100000  Security Lead   2011
1002 Saloni 85000 Database Admin 2012
1003 Karan 90000 Network Engineer Lead 2012
1004 Pratik 98000 TrainEngine Driver 2012
1005 Ashish 120000 Senior Consultant 2013
1006 Gautam 70000 Salesforce Consultant 2013
1007 Mohit Sacheva 20000 Peon 2014

谁能告诉我为什么会这样?时间差

最佳答案

您的表未正确创建。假设您的表名是 my_table。你应该包括

'PARTITIONED BY (year string)'

所以你的创建表应该如下所示

DROP TABLE IF EXISTS my_table;
CREATE EXTERNAL TABLE my_table
(col1 string,
col2 string,
col3 string)
PARTITIONED BY (year string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
STORED AS TEXTFILE
LOCATION '/home/rvarun/2012/part2012';

如果要使用列名作为 DoJ,只需将分区中的年份替换为 DoJ。

关于hadoop - 无法在 Hive 上对表进行分区 - 元数据错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34097207/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com