[
https://issues.apache.org/jira/browse/HIVE-25677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17447225#comment-17447225
]
Zhihua Deng commented on HIVE-25677:
------------------------------------
At 2.3.7, you should create a Configuration instance for the parser,
{code:java}
HiveConf hiveConf = new HiveConf();
hiveConf.set("_hive.hdfs.session.path", "/tmp");
hiveConf.set("_hive.local.session.path", "/tmp");
Context context = new Context(hiveConf);
ASTNode root = ParseUtils.parse("SELECT a,b,c `中国` from tbl", context);
System.out.println(root.dump()); {code}
The master branch seems have resolved the problem.
> HiveParser cannot parse a sql with chinese
> ------------------------------------------
>
> Key: HIVE-25677
> URL: https://issues.apache.org/jira/browse/HIVE-25677
> Project: Hive
> Issue Type: Bug
> Reporter: mysid2018
> Assignee: Zhihua Deng
> Priority: Major
>
> {color:#cc7832}I hope someone can help me。{color}
> {color:#cc7832}I write a program to parse the HQL. {color}{color:#cc7832}My
> code is as follows{color}
> {code:java}
> try {
> String mySql = "SELECT a,b,c as `中国` from tbl"
> ASTNode ast = ParseUtils.parse(mySql);
> ...
> } catch (Exception e) {
> LOG.info("parse_sql exception: {}", e.getMessage());
> ...
> }
> {code}
> It will print the log:
>
> {code:java}
> parse_sql exception: line 1:21 cannot recognize input near 'as' 'from' 'tbl'
> in selection target
> {code}
>
>
> The following code can run correctly
> {code:java}
> String mySql = "SELECT a,b,c as `china` from tbl"
> {code}
> Thanks very much.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)