mirror of https://github.com/alibaba/druid.git
Support impala refresh table.
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (11, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (17, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (21, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (8, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (11, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (17, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (21, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (8, ubuntu-latest) (push) Waiting to run
Details
This commit is contained in:
parent
6c2012851c
commit
5e426599d8
|
@ -4,12 +4,20 @@ import com.alibaba.druid.sql.ast.SQLExpr;
|
|||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SQLRefreshTableStatement extends SQLStatementImpl {
|
||||
private SQLExpr name;
|
||||
private List<SQLAssignItem> partitions;
|
||||
public SQLRefreshTableStatement() {
|
||||
partitions = new ArrayList<>();
|
||||
}
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, name);
|
||||
acceptChild(visitor, partitions);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
@ -24,4 +32,19 @@ public class SQLRefreshTableStatement extends SQLStatementImpl {
|
|||
}
|
||||
this.name = x;
|
||||
}
|
||||
|
||||
public List<SQLAssignItem> getPartitions() {
|
||||
return partitions;
|
||||
}
|
||||
|
||||
public void setPartitions(List<SQLAssignItem> partitions) {
|
||||
this.partitions = partitions;
|
||||
}
|
||||
|
||||
public void addPartition(SQLAssignItem partition) {
|
||||
if (partition != null) {
|
||||
partition.setParent(this);
|
||||
}
|
||||
this.partitions.add(partition);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,10 @@ package com.alibaba.druid.sql.dialect.impala.parser;
|
|||
import com.alibaba.druid.DbType;
|
||||
import com.alibaba.druid.sql.ast.SQLHint;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLAssignItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertInto;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRefreshTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.hive.parser.HiveSelectParser;
|
||||
import com.alibaba.druid.sql.dialect.hive.parser.HiveStatementParser;
|
||||
import com.alibaba.druid.sql.dialect.impala.stmt.ImpalaInsertStatement;
|
||||
|
@ -68,4 +70,24 @@ public class ImpalaStatementParser extends HiveStatementParser {
|
|||
this.getExprParser().parseHints(hints);
|
||||
}
|
||||
}
|
||||
|
||||
public SQLStatement parseRefresh() {
|
||||
acceptIdentifier("REFRESH");
|
||||
SQLRefreshTableStatement stmt = new SQLRefreshTableStatement();
|
||||
stmt.setDbType(dbType);
|
||||
stmt.setName(this.exprParser.name());
|
||||
if (lexer.nextIf(Token.PARTITION)) {
|
||||
for (; ; ) {
|
||||
SQLAssignItem item = this.exprParser.parseAssignItem(true, stmt);
|
||||
item.setParent(stmt);
|
||||
stmt.getPartitions().add(item);
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
lexer.nextToken();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,4 +239,15 @@ public class ImpalaOutputVisitor extends HiveOutputVisitor implements ImpalaASTV
|
|||
super.printSqlSetQuantifier(x);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLRefreshTableStatement x) {
|
||||
print0(ucase ? "REFRESH " : "refresh ");
|
||||
x.getName().accept(this);
|
||||
if (!x.getPartitions().isEmpty()) {
|
||||
print0(ucase ? " PARTITION " : " partition ");
|
||||
printAndAccept(x.getPartitions(), ", ");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
REFRESH test.test
|
||||
--------------------
|
||||
REFRESH test.test
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
REFRESH test.test PARTITION a=1
|
||||
--------------------
|
||||
REFRESH test.test PARTITION a = 1
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
COMPUTE INCREMENTAL STATS test.test
|
||||
--------------------
|
||||
COMPUTE INCREMENTAL STATS test.test
|
||||
|
|
Loading…
Reference in New Issue