mirror of https://github.com/alibaba/druid.git
Support compute incremental stats statement.
This commit is contained in:
parent
8333677a98
commit
6c2012851c
|
@ -0,0 +1,39 @@
|
|||
package com.alibaba.druid.sql.ast;
|
||||
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLComputeIncrementalStatsStatement extends SQLStatementImpl {
|
||||
private SQLExpr name;
|
||||
private SQLExpr partition;
|
||||
|
||||
public SQLExpr getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(SQLExpr name) {
|
||||
if (name != null) {
|
||||
name.setParent(this);
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public SQLExpr getPartition() {
|
||||
return partition;
|
||||
}
|
||||
|
||||
public void setPartition(SQLExpr partition) {
|
||||
if (partition != null) {
|
||||
partition.setParent(this);
|
||||
}
|
||||
this.partition = partition;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor v) {
|
||||
if (v.visit(this)) {
|
||||
acceptChild(v, name);
|
||||
acceptChild(v, partition);
|
||||
}
|
||||
v.endVisit(this);
|
||||
}
|
||||
}
|
|
@ -688,6 +688,12 @@ public class SQLStatementParser extends SQLParser {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token == COMPUTE) {
|
||||
SQLStatement stmt = parseCompute();
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
int size = statementList.size();
|
||||
if (parseStatementListDialect(statementList)) {
|
||||
if (parent != null) {
|
||||
|
@ -7805,6 +7811,18 @@ public class SQLStatementParser extends SQLParser {
|
|||
}
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLComputeIncrementalStatsStatement parseCompute() {
|
||||
accept(COMPUTE);
|
||||
acceptIdentifier("INCREMENTAL");
|
||||
acceptIdentifier("STATS");
|
||||
SQLComputeIncrementalStatsStatement stmt = new SQLComputeIncrementalStatsStatement();
|
||||
stmt.setName(this.exprParser.expr());
|
||||
if (lexer.nextIf(PARTITION)) {
|
||||
stmt.setPartition(this.exprParser.expr());
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
public SQLStartTransactionStatement parseStart() {
|
||||
acceptIdentifier("START");
|
||||
acceptIdentifier("TRANSACTION");
|
||||
|
|
|
@ -12327,6 +12327,16 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(SQLComputeIncrementalStatsStatement x) {
|
||||
print0(ucase ? "COMPUTE INCREMENTAL STATS " : "compute incremental stats ");
|
||||
x.getName().accept(this);
|
||||
if (x.getPartition() != null) {
|
||||
print0(ucase ? " PARTITION " : " partition ");
|
||||
x.getPartition().accept(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean visit(SQLExceptionStatement.Item x) {
|
||||
print0(ucase ? "WHEN " : "when ");
|
||||
|
|
|
@ -2735,6 +2735,13 @@ public interface SQLASTVisitor {
|
|||
|
||||
default void endVisit(SQLTypeExpr x) {
|
||||
}
|
||||
|
||||
default boolean visit(SQLComputeIncrementalStatsStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
default void endVisit(SQLComputeIncrementalStatsStatement x) {
|
||||
}
|
||||
static SQLASTVisitor ofMethodInvoke(Consumer<SQLMethodInvokeExpr> p) {
|
||||
return ofMethodInvoke(null, p);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
COMPUTE INCREMENTAL STATS test.test
|
||||
--------------------
|
||||
COMPUTE INCREMENTAL STATS test.test
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
COMPUTE INCREMENTAL STATS test.test PARTITION p1
|
||||
--------------------
|
||||
COMPUTE INCREMENTAL STATS test.test PARTITION p1
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
SELECT
|
||||
straight_join o.org_new_no AS org_new_no --AD店铺代号(机构最新编码)
|
||||
,
|
||||
|
|
Loading…
Reference in New Issue