Hive PARTITIONED BY, list index out of range error?
I am running Hive and Hue on Cloudera. I have the following text file uploaded to hdfs. And I'm trying to create an external table in hive partitioned by id. For whatever reason, it's not working.
id,name,age 1,sam,10 2,john,5 1,rick,4
CREATE EXTERNAL TABLE IF NOT EXISTS testDB ( name STRING, age INT ) COMMENT 'This is the test database' PARTITIONED BY (id INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LOCATION '/user/test2/' TBLPROPERTIES ("skip.header.line.count" = "1");
On Hue, hive editor, when I tried to look at sample data, it says list index out of range. Not sure what this is. The external table will work correctly if I remove the partitioned by.
Your data located on '/user/test2/test.csv' is structured on three columns, but your schema defined for the table 'testDB' contains two columns, it is normal that you have this error. You have to update your script, by adding the id column:
CREATE EXTERNAL TABLE IF NOT EXISTS testDB ( id INT, name STRING, age INT ) ...