-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mcy
committed
Nov 2, 2024
1 parent
de4a560
commit 4522bb8
Showing
29 changed files
with
1,375 additions
and
1,151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 0 additions & 72 deletions
72
ares-common/src/main/java/com/github/ares/common/utils/PasswordUtil.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
ares-parser/src/main/java/com/github/ares/parser/sqlparser/sparksql/CommonParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.github.ares.parser.sqlparser.sparksql; | ||
|
||
import com.github.ares.api.common.CriteriaClause; | ||
import com.github.ares.org.antlr.v4.runtime.CharStream; | ||
import com.github.ares.org.antlr.v4.runtime.CharStreams; | ||
import com.github.ares.org.antlr.v4.runtime.CommonTokenStream; | ||
import com.github.ares.parser.antlr4.CaseChangingCharStream; | ||
import com.github.ares.parser.antlr4.CustomErrorListener; | ||
import com.github.ares.parser.antlr4.sparksql.SqlBaseLexer; | ||
import com.github.ares.parser.antlr4.sparksql.SqlBaseParser; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.List; | ||
|
||
public class CommonParser { | ||
|
||
public static final String UNSUPPORTED_EXP_MSG = "unsupported syntax: "; | ||
public static final String UNSUPPORTED_EXP_MSG_WITH_PARAM = UNSUPPORTED_EXP_MSG + " %s"; | ||
|
||
public static final String SQL_SELECT_PREFIX = "SELECT "; | ||
|
||
public static SqlBaseParser parseSql(InputStream in) throws IOException { | ||
CharStream s = CharStreams.fromStream(in); | ||
CaseChangingCharStream upper = new CaseChangingCharStream(s, true); | ||
|
||
CustomErrorListener lexerErrorListener = new CustomErrorListener(); | ||
SqlBaseLexer lexer = new SqlBaseLexer(upper); | ||
lexer.removeErrorListeners(); | ||
lexer.addErrorListener(lexerErrorListener); | ||
CommonTokenStream tokens = new CommonTokenStream(lexer); | ||
SqlBaseParser parser = new SqlBaseParser(tokens); | ||
CustomErrorListener parserErrorListener = new CustomErrorListener(); | ||
parser.removeErrorListeners(); | ||
parser.addErrorListener(parserErrorListener); | ||
return parser; | ||
} | ||
|
||
public static void visitCriteriaClause(CriteriaClause criteriaClause, List<String> items) { | ||
if ("AND".equalsIgnoreCase(criteriaClause.getOperator()) || "OR".equalsIgnoreCase(criteriaClause.getOperator())) { | ||
visitCriteriaClause(criteriaClause.getLeftCriteria(), items); | ||
visitCriteriaClause(criteriaClause.getRightCriteria(), items); | ||
} else { | ||
if ("IN".equalsIgnoreCase(criteriaClause.getOperator())) { | ||
if (criteriaClause.getInItems() != null) { | ||
items.addAll(criteriaClause.getInItems()); | ||
} | ||
} else { | ||
items.add(criteriaClause.getRightExpr()); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.