Failed to recognize predicate 'xxx'. Failed rule: 'identifier' in column specification

1. 问题描述

在Hive1.2.2版本运行如下HQL时:

select dt as date, comMap['searchType'] as search_type, comMap['clickType'] as click_type
from search_click
where dt = '20170614';

会抛出如下异常:

Failed to recognize predicate 'date'. Failed rule: 'identifier' in column specification

2. 问题分析

在Hive1.2.0版本开始增加了如下配置选项,默认值为true

hive.support.sql11.reserved.keywords

该选项的目的是:是否启用对SQL2011保留关键字的支持。 启用后,将支持部分SQL2011保留关键字。

3. 解决方案

从上面可以知道是因为启用了对保留关键字的支持导致的,上面语句中date是保留关键字.所以解决方案如下:

  • 弃用保留关键字date
select dt, comMap['searchType'] as search_type, comMap['clickType'] as click_type
from search_click
where dt = '20170614';
  • 弃用对保留关键字的支持
sudo -uwirelessdev hive -e "
   set hive.support.sql11.reserved.keywords = false ;
   select dt, comMap['searchType'] as search_type, comMap['clickType'] as click_type
   from search_click
   where dt = '20170614';
" > a.txt

或者在conf下的hive-site.xml配置文件中修改配置选项:

<property>
    <name>hive.support.sql11.reserved.keywordsname>
    <value>falsevalue>
property>

你可能感兴趣的:(Hive)