Impala – Reserved Keywords as Columns

In programming languages, or in any database platforms a reserved word (also known as a reserved identifier) is a word that cannot be used as explicitly an identifier, such as the name of a variable, method, function, or label – it is reserved from use. This is because it ensures optimum consistency between items and variants.

What happens if we use Cloudera Impala’s reserved keywords as columns?
Obviously it will return an error. See the below example.

Hive Table Reserved Keywords
I have created a table in Hive with the Impala’s reserved keywords as columns.
Let’s check what it returns in Impala when retrieved.

Error in Impala

It returned an error saying “AnalysisException: Syntax error in line 1:
Encountered: DATE

Eventually it will return error for ‘array’ and ‘avg’ as well. One must avoid such columns names in the first place. If you need to use it as an identifier, you need to quote it with backticks as shown below.

SELECT `date`, `array`, `avg` FROM SampleTable;

Reserved Keyword - Solution

3 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s