You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "ZhuMinghui (Jira)" <ji...@apache.org> on 2022/10/08 07:51:00 UTC

[jira] [Commented] (IMPALA-11566) Provide SQL parsing capabilities to other applications in the form of jar packages

    [ https://issues.apache.org/jira/browse/IMPALA-11566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17614401#comment-17614401 ] 

ZhuMinghui commented on IMPALA-11566:
-------------------------------------

https://gerrit.cloudera.org/#/c/19023/

> Provide SQL parsing capabilities to other applications in the form of jar packages
> ----------------------------------------------------------------------------------
>
>                 Key: IMPALA-11566
>                 URL: https://issues.apache.org/jira/browse/IMPALA-11566
>             Project: IMPALA
>          Issue Type: New Feature
>            Reporter: ZhuMinghui
>            Assignee: ZhuMinghui
>            Priority: Major
>
> We have a requirement to rewrite the parameters of a function in SQL, and there will be more requirements related to SQL parsing in the future. Before, we used jsqlParser for parsing. In order to be more compatible with impala sql, we want to use impala's parser.
> Not all statements currently support the toSql method, so to provide complete parsing capabilities, it is also necessary to support the toSql method of other statements, such as AlterTableStmt. But in our scenario, there are only select and use statements, which are already supported. So all we need to do is to analyze all the functions in sql and type out the parser package.
> We can rely on it in the pom in another project:
> {code:java}
> <dependency>
>     <groupId>org.apache.impala</groupId>
>     <artifactId>impala-parser</artifactId>
>     <version>${impala.version}</version>
> </dependency> {code}
> And then we can rewrite the sql:
> {code:java}
> public String parse(String sql) {
>   StatementBase node = Parser.parse(sql);
>   FunctionCallExprVisitor functionCallExprVisitor = new FunctionCallExprVisitor();
>   node.accept(functionCallExprVisitor);
>   List<FunctionCallExpr> funcCalls = functionCallExprVisitor.getFuncCalls();
>   // do something with funcCalla
>   return node.toSql();
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org