mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved odps & hive sql parser support.
This commit is contained in:
@@ -31,6 +31,7 @@ public class OdpsCreateTableStatement extends SQLCreateTableStatement {
|
||||
|
||||
private SQLExprTableSource like;
|
||||
|
||||
protected SQLExpr storedBy;
|
||||
protected SQLExpr lifecycle;
|
||||
|
||||
public OdpsCreateTableStatement(){
|
||||
@@ -69,9 +70,21 @@ public class OdpsCreateTableStatement extends SQLCreateTableStatement {
|
||||
this.acceptChild(visitor, partitionColumns);
|
||||
this.acceptChild(visitor, clusteredBy);
|
||||
this.acceptChild(visitor, sortedBy);
|
||||
this.acceptChild(visitor, storedBy);
|
||||
this.acceptChild(visitor, lifecycle);
|
||||
this.acceptChild(visitor, select);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLExpr getStoredBy() {
|
||||
return storedBy;
|
||||
}
|
||||
|
||||
public void setStoredBy(SQLExpr x) {
|
||||
if (x != null) {
|
||||
x.setParent(this);
|
||||
}
|
||||
this.storedBy = x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.odps.parser;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
@@ -178,6 +179,19 @@ public class OdpsCreateTableParser extends SQLCreateTableParser {
|
||||
lexer.nextToken();
|
||||
stmt.setLifecycle(this.exprParser.expr());
|
||||
}
|
||||
|
||||
while (lexer.identifierEquals(FnvHash.Constants.STORED)) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.AS) {
|
||||
lexer.nextToken();
|
||||
SQLName storedAs = this.exprParser.name();
|
||||
stmt.setStoredAs(storedAs);
|
||||
} else {
|
||||
accept(Token.BY);
|
||||
SQLExpr storedBy = this.exprParser.expr();
|
||||
stmt.setStoredBy(storedBy);
|
||||
}
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@@ -161,6 +161,20 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
x.getLifecycle().accept(this);
|
||||
}
|
||||
|
||||
SQLExpr storedBy = x.getStoredBy();
|
||||
if (storedBy != null) {
|
||||
println();
|
||||
print0(ucase ? "STORED BY " : "stored by ");
|
||||
storedBy.accept(this);
|
||||
}
|
||||
|
||||
SQLExpr storedAs = x.getStoredAs();
|
||||
if (storedAs != null) {
|
||||
println();
|
||||
print0(ucase ? "STORED AS " : "stored as ");
|
||||
storedAs.accept(this);
|
||||
}
|
||||
|
||||
if (x.getSelect() != null) {
|
||||
println();
|
||||
print0(ucase ? "AS" : "as");
|
||||
|
||||
Reference in New Issue
Block a user