Support Questions

Find answers, ask questions, and share your expertise

Hive: Query keyword column name

avatar
Expert Contributor

Have an external HIVE table that is based on an avro files and one of the column description is as below. When trying to do SELECT on that with header.timestamp, it fails with the error below. Is there way to query columns with the keywords?

col_name data_type

header struct<versionnum:binary, timestamp:bigint,uuid:binary>

Error:

Error while compiling statement: FAILED: ParseException line 1:80 Failed to recognize predicate 'timestamp'. Failed rule: 'identifier' in expression specification

1 ACCEPTED SOLUTION

avatar
Super Collaborator
4 REPLIES 4

avatar
Super Collaborator

avatar
Super Guru
@Kumar

Try using back ticks ` around the column name like `column`.

avatar
Expert Contributor

Thanks,

After doing "set hive.support.sql11.reserved.keywords=false", it allows to query the column with the keyword.

When using back quotes, it gives the following error:

select `header.timestamp` from avro_test_channel;

FAILED: SemanticException [Error 10004]: Line 1:7 Invalid table alias or column reference 'header.timestamp': (possible column names are:

avatar
New Contributor

For the backtick approach, you might want to try `header`.`timestamp`