0
votes

I have a simple table created in Cloudera CDH. The version used is Hive 1.1.0 CDH 5.8.

create table student(id decimal, name varchar(100), valid char(1) ) 
clustered by (id) into 2 buckets 
stored as orc TBLPROPERTIES('transactional'='true');

When I try to execute an insert statement

insert into student (id,name,valid) values (1, 'ABC', 'Y');

It gives the following error

NoViableAltException Cannot recognize input near '(' ''id'' ',' in statement

If I omit the column names in the insert query, it works fine. I tried the same thing on Apache Hive, and the insert query with column name works fine.

I want to specify the column names in the insert query, as i will be inserting into a subset of columns. Any pointers on how to get this to work?

Thanks

1

1 Answers

1
votes

Column list specification in INSERT statement is supported as of Hive 1.2
https://issues.apache.org/jira/browse/HIVE-9481

For earlier versions you should insert values to all the columns by their order in the destination table.
For some of the columns you may need to use hard-coded values -
NULL or some default values.