Skip to content

Commit

Permalink
Fix sr visitor issue. (#6245)
Browse files Browse the repository at this point in the history
* Fix sr visitor issue.

* Fix sr visitor issue.

* Fix sr visitor issue.
  • Loading branch information
lingo-xp authored Nov 22, 2024
1 parent 64c4e70 commit 83428b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem;
import com.alibaba.druid.sql.dialect.starrocks.ast.StarRocksObject;
import com.alibaba.druid.sql.dialect.starrocks.visitor.StarRocksASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -62,17 +61,11 @@ public void setOrderBy(SQLOrderBy orderBy) {
this.orderBy = orderBy;
}

@Override
protected void accept0(SQLASTVisitor v) {
if (v instanceof StarRocksASTVisitor) {
accept0((StarRocksASTVisitor) v);
}
}

@Override
public void accept0(StarRocksASTVisitor v) {
if (v.visit(this)) {
acceptChild(v);
acceptChild(v, engine);
acceptChild(v, orderBy);
}
v.endVisit(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,7 @@ protected void printEngine(SQLCreateTableStatement x) {
}

public boolean visit(StarRocksCreateTableStatement x) {
print0(ucase ? "CREATE " : "create ");
printCreateTableFeatures(x);
print0(ucase ? "TABLE " : "table ");
if (x.isIfNotExists()) {
print0(ucase ? "IF NOT EXISTS " : "if not exists ");
}
printTableSourceExpr(
x.getTableSource()
.getExpr());
printCreateTableAfterName(x);
printTableElements(x.getTableElementList());
printCreateTable(x, false);
printEngine(x);
printUniqueKey(x);
printComment(x.getComment());
Expand All @@ -72,16 +62,13 @@ public boolean visit(StarRocksCreateTableStatement x) {
return false;
}

@Override
public boolean visit(SQLCreateTableStatement x) {
printCreateTable(x, false);
printEngine(x);
printComment(x.getComment());
printPartitionBy(x);
printDistributedBy(x);
printOrderBy(x);
printTableOptions(x);
printSelectAs(x, true);
return false;
if (x instanceof StarRocksCreateTableStatement) {
return visit((StarRocksCreateTableStatement) x);
} else {
return super.visit(x);
}
}
protected void printCreateTable(SQLCreateTableStatement x, boolean printSelect) {
print0(ucase ? "CREATE " : "create ");
Expand Down

0 comments on commit 83428b9

Please sign in to comment.