Skip to content

Commit

Permalink
use the calcite dependency of flink
Browse files Browse the repository at this point in the history
  • Loading branch information
wg1026688210 committed Jun 17, 2024
1 parent 5b7e645 commit 7df2f32
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,19 @@ private ClassLoader initCalciteClassLoader() throws Exception {
}

public Predicate convertSqlToPredicate(String conditionSql) throws SqlParseException {
ClassLoader pre = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(calciteClassLoader);
return convert(conditionSql);
} finally {
Thread.currentThread().setContextClassLoader(pre);
}
return convert(conditionSql);
}

Predicate convert(String conditionSql) throws SqlParseException {
ClassLoader pre = Thread.currentThread().getContextClassLoader();

try {
Thread.currentThread().setContextClassLoader(calciteClassLoader);
Class<?> calciteParserClass =
Class.forName("org.apache.flink.table.planner.parse.CalciteParser");
Class.forName(
"org.apache.flink.table.planner.parse.CalciteParser",
true,
calciteClassLoader);
System.out.println("是否能找到?");
// 获取它的构造函数(假设有可访问的公共构造函数)
Constructor<?> constructor = calciteParserClass.getConstructor(SqlParser.Config.class);
Expand All @@ -115,6 +114,8 @@ Predicate convert(String conditionSql) throws SqlParseException {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} finally {
Thread.currentThread().setContextClassLoader(pre);
}
}

Expand Down

0 comments on commit 7df2f32

Please sign in to comment.