mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
support clickhouse asof join
This commit is contained in:
@@ -154,6 +154,14 @@ public class SQLParser {
|
||||
return null;
|
||||
}
|
||||
return ident;
|
||||
} else if (hash == FnvHash.Constants.ASOF && dbType == DbType.clickhouse) {
|
||||
Lexer.SavePoint mark = lexer.mark();
|
||||
lexer.nextToken();
|
||||
if (lexer.token == Token.LEFT || lexer.token == Token.JOIN) {
|
||||
lexer.reset(mark);
|
||||
return null;
|
||||
}
|
||||
return ident;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1151,7 +1151,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
&& ((hash = lexer.hash_lower()) == FnvHash.Constants.STRAIGHT_JOIN
|
||||
|| hash == FnvHash.Constants.CROSS)))
|
||||
{
|
||||
String alias = tableAlias();
|
||||
String alias = tableAlias(false);
|
||||
if (alias != null) {
|
||||
if (isEnabled(SQLParserFeature.IgnoreNameQuotes) && alias.length() > 1) {
|
||||
alias = StringUtils.removeNameQuotes(alias);
|
||||
@@ -1192,6 +1192,12 @@ public class SQLSelectParser extends SQLParser {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
boolean asof = false;
|
||||
if (lexer.identifierEquals(FnvHash.Constants.ASOF) && dbType == DbType.clickhouse) {
|
||||
lexer.nextToken();
|
||||
asof = true;
|
||||
}
|
||||
|
||||
switch (lexer.token) {
|
||||
case LEFT:
|
||||
lexer.nextToken();
|
||||
@@ -1276,6 +1282,9 @@ public class SQLSelectParser extends SQLParser {
|
||||
SQLJoinTableSource join = new SQLJoinTableSource();
|
||||
join.setLeft(tableSource);
|
||||
join.setJoinType(joinType);
|
||||
if (asof) {
|
||||
join.setAsof(true);
|
||||
}
|
||||
|
||||
boolean isBrace = false;
|
||||
if (SQLJoinTableSource.JoinType.COMMA == joinType) {
|
||||
|
||||
Reference in New Issue
Block a user