mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
support clickhouse nested datatype/create table engine, fix #4106
This commit is contained in:
@@ -3675,6 +3675,46 @@ public class SQLExprParser extends SQLParser {
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.ROW) || lexer.token == Token.ROW) {
|
||||
lexer.nextToken();
|
||||
return parseSqlRowDataType();
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.NESTED) && dbType == DbType.clickhouse) {
|
||||
lexer.nextToken();
|
||||
accept(Token.LPAREN);
|
||||
|
||||
SQLStructDataType struct = new SQLStructDataType(dbType);
|
||||
|
||||
for (;;) {
|
||||
SQLName name;
|
||||
switch (lexer.token) {
|
||||
case GROUP:
|
||||
case ORDER:
|
||||
case FROM:
|
||||
case TO:
|
||||
name = new SQLIdentifierExpr(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
break;
|
||||
default:
|
||||
name = this.name();
|
||||
break;
|
||||
}
|
||||
|
||||
SQLDataType dataType = this.parseDataType();
|
||||
SQLStructDataType.Field field = struct.addField(name, dataType);
|
||||
|
||||
if (lexer.token == Token.COMMENT) {
|
||||
lexer.nextToken();
|
||||
SQLCharExpr chars = (SQLCharExpr) this.primary();
|
||||
field.setComment(chars.getText());
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
lexer.nextToken();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
accept(Token.RPAREN);
|
||||
|
||||
return struct;
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.UNIONTYPE)) {
|
||||
|
||||
Reference in New Issue
Block a user