Support Questions
Find answers, ask questions, and share your expertise

Hive: Query keyword column name

Rising Star

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

Accepted Solutions

Expert Contributor
4 REPLIES 4

Expert Contributor

@Kumar

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

Rising Star

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:

New Contributor

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