Hive 编程专题 之 - 使用正则指定输出列
![作者头像](https://ask.qcloudimg.com/custom-avatar/1045366/1cab7nq7xy.jpg)
环境:
Hive: 2.7.7
Oracle SQL Developer
Cloudera JDBC Driver
案例:
select type,nameobject,`*date`
from tblobj2
limit 10 ;
错误:
1 - 使用 Oracle SQL Developer 执行上述 HQL 语句报错:
[Cloudera][HiveJDBCDriver](500051) ERROR processing query/statement. Error Code: 40000, SQL state: TStatus(statusCode:ERROR_STATUS, infoMessages:[*org.apache.hive.service.cli.HiveSQLException:Error while compiling statement: FAILED: SemanticException Line 1:23 Invalid column reference '`*date`': Dangling meta character '*' near index 0
*date
....(省却其他错误输出)
java.lang.Thread:run:Thread.java:745, *org.apache.hadoop.hive.ql.parse.SemanticException:Line 1:23 Invalid column reference '`*date`': Dangling meta character '*' near index 0
*date
....(省却其他错误输出)
sqlState:42000, errorCode:40000, errorMessage:Error while compiling statement: FAILED: SemanticException Line 1:23 Invalid column reference '`*date`': Dangling meta character '*' near index 0
*date
^), Query: select type,nameobject,`*date`
from tblobj2
limit 10.
2 - 使用 Hive 同样 也报错:
hive> select nameobject,type,`*date` from tblobj2 limit 10 ;
FAILED: SemanticException [Error 10004]: Line 1:23 Invalid table alias or column reference '*date': (possible column names are: nameobject, object_id, principal_id, schema_id, parent_object_id, type, type_desc, create_date, modify_date, is_ms_shipped, is_published, is_schema_published)
解决方案:
set hive.support.quoted.identifiers=none