This is an automated email from the ASF dual-hosted git repository.

zykkk pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new c1522202f4a [improvement](catalog) fix jdbc mysql catalog to_date fun 
pushdown (#29900) (#30778)
c1522202f4a is described below

commit c1522202f4af63e5b2ad7983b586dd3ab2f47d66
Author: zy-kkk <[email protected]>
AuthorDate: Fri Feb 2 23:05:50 2024 +0800

    [improvement](catalog) fix jdbc mysql catalog to_date fun pushdown (#29900) 
(#30778)
---
 .../doris/planner/external/jdbc/JdbcFunctionPushDownRule.java       | 1 +
 .../data/external_table_p0/jdbc/test_mysql_jdbc_catalog.out         | 6 ++++++
 .../suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy    | 6 ++++++
 3 files changed, 13 insertions(+)

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 3678fa1a40c..d328952593f 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
@@ -72,6 +72,7 @@ public class JdbcFunctionPushDownRule {
 
     static {
         REPLACE_MYSQL_FUNCTIONS.put("nvl", "ifnull");
+        REPLACE_MYSQL_FUNCTIONS.put("to_date", "date");
     }
 
     private static boolean isReplaceMysqlFunctions(String functionName) {
diff --git 
a/regression-test/data/external_table_p0/jdbc/test_mysql_jdbc_catalog.out 
b/regression-test/data/external_table_p0/jdbc/test_mysql_jdbc_catalog.out
index 500f48b77a2..af836d95c02 100644
--- a/regression-test/data/external_table_p0/jdbc/test_mysql_jdbc_catalog.out
+++ b/regression-test/data/external_table_p0/jdbc/test_mysql_jdbc_catalog.out
@@ -185,6 +185,12 @@ bca        2022-11-02      2022-11-02      8012    vivo
 -- !ex_tb21_6 --
 1      1
 
+-- !ex_tb21_7 --
+2      1
+
+-- !ex_tb21_8 --
+2      2
+
 -- !information_schema --
 CHARACTER_SETS
 COLLATIONS
diff --git 
a/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy 
b/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy
index ec09d2a319d..fdc1f84e382 100644
--- 
a/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy
+++ 
b/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy
@@ -172,6 +172,8 @@ suite("test_mysql_jdbc_catalog", 
"p0,external,mysql,external_docker,external_doc
             order_qt_ex_tb21_4  """ select `key`, `id` from ${ex_tb21} where 
abs(`key`) = 2 order by id;"""
             order_qt_ex_tb21_5  """ select `key`, `id` from ${ex_tb21} where 
`key` between 1 and 2 order by id;"""
             order_qt_ex_tb21_6  """ select `key`, `id` from ${ex_tb21} where 
`key` = case when id = 1 then 1 else 0 end order by id;"""
+            order_qt_ex_tb21_7  """ select (`key` +1) as k, `id` from 
${ex_tb21} having abs(k) = 2 order by id;"""
+            order_qt_ex_tb21_8  """ select `key` as k, `id` from ${ex_tb21} 
having abs(k) = 2 order by id;"""
             order_qt_information_schema """ show tables from 
information_schema; """
             order_qt_auto_default_t """insert into ${auto_default_t}(name) 
values('a'); """
             order_qt_dt """select * from ${dt}; """
@@ -179,6 +181,10 @@ suite("test_mysql_jdbc_catalog", 
"p0,external,mysql,external_docker,external_doc
             order_qt_test_dz """select * from ${test_zd} order by 1; """
             order_qt_test_filter_not """select * from ${ex_tb13} where name 
not like '%张三0%' order by 1; """
             order_qt_test_filter_not_old_plan """select /*+ 
SET_VAR(enable_nereids_planner=false) */ * from ${ex_tb13} where name not like 
'%张三0%' order by 1; """
+            explain {
+                sql("select `datetime` from all_types where 
to_date(`datetime`) = '2012-10-25';")
+                contains """ SELECT `datetime` FROM `doris_test`.`all_types` 
WHERE (date(`datetime`) = '2012-10-25')"""
+            }
 
             // test insert
             String uuid1 = UUID.randomUUID().toString();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to