support clickhouse asof join

This commit is contained in:
高铁
2020-12-26 14:11:20 +08:00
parent 8db98751e6
commit c22f0f0bfd
7 changed files with 50 additions and 1 deletions
@@ -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) {