diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/external/jdbc/JdbcFunctionPushDownRule.java b/fe/fe-core/src/main/java/org/apache/doris/planner/external/jdbc/JdbcFunctionPushDownRule.java index d1a44cb700..35d069c12c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/external/jdbc/JdbcFunctionPushDownRule.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/external/jdbc/JdbcFunctionPushDownRule.java @@ -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 children = expr.getChildren(); diff --git a/regression-test/data/external_table_p0/jdbc/test_clickhouse_jdbc_catalog.out b/regression-test/data/external_table_p0/jdbc/test_clickhouse_jdbc_catalog.out index 05372e3f0a..d6591a4828 100644 Binary files a/regression-test/data/external_table_p0/jdbc/test_clickhouse_jdbc_catalog.out and b/regression-test/data/external_table_p0/jdbc/test_clickhouse_jdbc_catalog.out differ diff --git a/regression-test/suites/external_table_p0/jdbc/test_clickhouse_jdbc_catalog.groovy b/regression-test/suites/external_table_p0/jdbc/test_clickhouse_jdbc_catalog.groovy index b01f200574..8fb0f32399 100644 --- a/regression-test/suites/external_table_p0/jdbc/test_clickhouse_jdbc_catalog.groovy +++ b/regression-test/suites/external_table_p0/jdbc/test_clickhouse_jdbc_catalog.groovy @@ -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} """