如何使用关键字做字段
在使用hive做数据查询时碰到使用date做字段,进行查询时报了以下错误
select quantity,date as pre_date,inc_day from table
Error while compiling statement: FAILED: ParseException line 1:9 Failed to recognize predicate 'date'. Failed rule: 'identifier' in table or column identifier
依据以上错误,可知date在SQL语言中为关键字,用为字段名时,无法直接使用,需要加上倒引号,才可识别,在建表时也需加倒引号进行使用。
select quantity,`date` ,inc_day from table
limit 100
查询结果输出如下