[improvement](jdbc catalog) Adjust function replacement order and add new function support (#24685)
This commit is contained in:
@ -45,6 +45,7 @@ public class JdbcFunctionPushDownRule {
|
||||
|
||||
static {
|
||||
CLICKHOUSE_SUPPORTED_FUNCTIONS.add("from_unixtime");
|
||||
CLICKHOUSE_SUPPORTED_FUNCTIONS.add("unix_timestamp");
|
||||
}
|
||||
|
||||
private static boolean isMySQLFunctionUnsupported(String functionName) {
|
||||
@ -70,6 +71,7 @@ public class JdbcFunctionPushDownRule {
|
||||
|
||||
static {
|
||||
REPLACE_CLICKHOUSE_FUNCTIONS.put("from_unixtime", "FROM_UNIXTIME");
|
||||
REPLACE_CLICKHOUSE_FUNCTIONS.put("unix_timestamp", "toUnixTimestamp");
|
||||
}
|
||||
|
||||
private static boolean isReplaceClickHouseFunctions(String functionName) {
|
||||
@ -105,14 +107,14 @@ public class JdbcFunctionPushDownRule {
|
||||
|
||||
Preconditions.checkArgument(!func.isEmpty(), "function can not be empty");
|
||||
|
||||
func = replaceFunctionNameIfNecessary(func, replaceFunction, functionCallExpr, tableType);
|
||||
|
||||
if (!func.isEmpty() && checkFunction.test(func)) {
|
||||
if (checkFunction.test(func)) {
|
||||
String errMsg = "Unsupported function: " + func + " in expr: " + expr.toMySql()
|
||||
+ " in JDBC Table Type: " + tableType;
|
||||
LOG.warn(errMsg);
|
||||
errors.add(errMsg);
|
||||
}
|
||||
|
||||
replaceFunctionNameIfNecessary(func, replaceFunction, functionCallExpr, tableType);
|
||||
}
|
||||
|
||||
List<Expr> children = expr.getChildren();
|
||||
|
||||
Binary file not shown.
@ -75,7 +75,12 @@ suite("test_clickhouse_jdbc_catalog", "p0,external,clickhouse,external_docker,ex
|
||||
}
|
||||
explain {
|
||||
sql("select * from ts where nvl(ts,null) >= '2022-01-01';")
|
||||
contains """QUERY: SELECT "id", "ts" FROM "doris_test"."ts""""
|
||||
contains """QUERY: SELECT "id", "ts" FROM "doris_test"."ts"""
|
||||
}
|
||||
order_qt_func_push2 """select * from ts where ts <= unix_timestamp(from_unixtime(ts,'yyyyMMdd'));"""
|
||||
explain {
|
||||
sql("select * from ts where ts <= unix_timestamp(from_unixtime(ts,'yyyy-MM-dd'));")
|
||||
contains """QUERY: SELECT "id", "ts" FROM "doris_test"."ts" WHERE (ts <= toUnixTimestamp(FROM_UNIXTIME(ts, '%Y-%m-%d')))"""
|
||||
}
|
||||
|
||||
sql """ drop catalog if exists ${catalog_name} """
|
||||
|
||||
Reference in New Issue
Block a user