mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved hive support, fix #4056
This commit is contained in:
@@ -136,6 +136,10 @@ public class SQLUtils {
|
||||
return toOdpsString(sqlObject, null);
|
||||
}
|
||||
|
||||
public static String toHiveString(SQLObject sqlObject) {
|
||||
return toSQLString(sqlObject, DbType.odps);
|
||||
}
|
||||
|
||||
public static String toOdpsString(SQLObject sqlObject, FormatOption option) {
|
||||
return toSQLString(sqlObject, DbType.odps, option);
|
||||
}
|
||||
|
||||
+19
-13
@@ -103,6 +103,8 @@ public class HiveCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
|
||||
accept(Token.RPAREN);
|
||||
} else if (lexer.token() == Token.LIKE) {
|
||||
parseLike(stmt);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.ENGINE)) {
|
||||
@@ -274,19 +276,7 @@ public class HiveCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LIKE) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.MAPPING)) {
|
||||
SQLExpr like = this.exprParser.primary();
|
||||
stmt.setLike(new SQLExprTableSource(like));
|
||||
} else if (lexer.token() == Token.SELECT || lexer.token() == Token.LPAREN) {
|
||||
SQLSelect select = this.createSQLSelectParser().select();
|
||||
stmt.setLikeQuery(true);
|
||||
stmt.setSelect(select);
|
||||
} else {
|
||||
SQLName name = this.exprParser.name();
|
||||
stmt.setLike(name);
|
||||
}
|
||||
parseLike(stmt);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.TBLPROPERTIES)) {
|
||||
@@ -366,6 +356,22 @@ public class HiveCreateTableParser extends SQLCreateTableParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
protected void parseLike(HiveCreateTableStatement stmt) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.MAPPING)) {
|
||||
SQLExpr like = this.exprParser.primary();
|
||||
stmt.setLike(new SQLExprTableSource(like));
|
||||
} else if (lexer.token() == Token.SELECT || lexer.token() == Token.LPAREN) {
|
||||
SQLSelect select = this.createSQLSelectParser().select();
|
||||
stmt.setLikeQuery(true);
|
||||
stmt.setSelect(select);
|
||||
} else {
|
||||
SQLName name = this.exprParser.name();
|
||||
stmt.setLike(name);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseSortedBy(HiveCreateTableStatement stmt) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
|
||||
Reference in New Issue
Block a user