Minghui Zhu has uploaded a new patch set (#4). (
http://gerrit.cloudera.org:8080/19023 )
Change subject: IMPALA-11566: Provide SQL parsing capabilities to other
applications in the form of jar packages
......................................................................
IMPALA-11566: Provide SQL parsing capabilities to other applications in the
form of jar packages
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:
<dependency>
<groupId>org.apache.impala</groupId>
<artifactId>impala-parser</artifactId>
<version>${impala.version}</version>
</dependency>
And then we can rewrite the sql:
public String parse(String sql) {
StatementBase stmt = Parser.parse(sql);
ExprRewriter exprRewriter = new MyExprRewritter();
stmt.rewriteExprs(exprRewriter);
return stmt.toSql();
}
The MyExprRewriter class is not a common requirement, so it was not
submitted. This submission is mainly to support the construction of
the parser package.
It should be noted that it must be set in advance:
TBackendGflags tBackendGflags = new TBackendGflags();
tBackendGflags.setSkip_lookup_symbol(true);
BackendConfig.create(tBackendGflags);
Change-Id: I246b088310f25b809d9e598c0ecc6613d9749ee3
---
M be/src/util/backend-gflag-util.cc
M common/thrift/BackendGflags.thrift
M fe/pom.xml
M fe/src/main/java/org/apache/impala/analysis/SelectStmt.java
M fe/src/main/java/org/apache/impala/catalog/ScalarFunction.java
M fe/src/main/java/org/apache/impala/service/BackendConfig.java
6 files changed, 57 insertions(+), 0 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/23/19023/4
--
To view, visit http://gerrit.cloudera.org:8080/19023
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I246b088310f25b809d9e598c0ecc6613d9749ee3
Gerrit-Change-Number: 19023
Gerrit-PatchSet: 4
Gerrit-Owner: Minghui Zhu <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Jian Zhang <[email protected]>
Gerrit-Reviewer: Minghui Zhu <[email protected]>
Gerrit-Reviewer: Quanlong Huang <[email protected]>
Gerrit-Reviewer: Xiang Yang <[email protected]>