morningman commented on code in PR #21745:
URL: https://github.com/apache/doris/pull/21745#discussion_r1266913206


##########
fe/fe-core/src/main/java/org/apache/doris/planner/external/jdbc/JdbcFilterReplace.java:
##########
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.planner.external.jdbc;
+
+import org.apache.doris.thrift.TOdbcTableType;
+
+public class JdbcFilterReplace {

Review Comment:
   ```suggestion
   public class JdbcFunctionPushDownRule {
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/planner/external/jdbc/JdbcFilterReplace.java:
##########
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.planner.external.jdbc;
+
+import org.apache.doris.thrift.TOdbcTableType;
+
+public class JdbcFilterReplace {
+    public static String replaceUnsupportedFunctions(TOdbcTableType tableType, 
String filter) {
+        if (tableType.equals(TOdbcTableType.MYSQL)) {
+            return replaceMySQLFunctions(filter);
+        } else {
+            return filter;
+        }
+    }
+
+    private static String replaceMySQLFunctions(String filter) {
+        if (filter.contains("date_trunc")) {

Review Comment:
   Better define a `final static TreeSet<String>`(case insensitive set) to 
contain these function name. So that we only need to modify that Set to add new 
function names.



##########
fe/fe-core/src/main/java/org/apache/doris/planner/external/jdbc/JdbcFilterReplace.java:
##########
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.planner.external.jdbc;
+
+import org.apache.doris.thrift.TOdbcTableType;
+
+public class JdbcFilterReplace {
+    public static String replaceUnsupportedFunctions(TOdbcTableType tableType, 
String filter) {
+        if (tableType.equals(TOdbcTableType.MYSQL)) {
+            return replaceMySQLFunctions(filter);
+        } else {
+            return filter;
+        }
+    }
+
+    private static String replaceMySQLFunctions(String filter) {

Review Comment:
   Although it works, but not a proper way to return `null`.
   Better define a Enum as return code, which is more meaningful than this, eg:
   ```
   enum Status {
       SUPPORTED,
       NOT_SUPPORTED
   }
   ```



##########
docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md:
##########
@@ -89,7 +89,7 @@ select * from mysql_catalog.mysql_database.mysql_table where 
k1 > 1000 and k3 ='
 
 1. 当执行类似于 `where dt = '2022-01-01'` 这样的查询时,Doris 
能够将这些过滤条件下推到外部数据源,从而直接在数据源层面排除不符合条件的数据,减少了不必要的数据获取和传输。这大大提高了查询性能,同时也降低了对外部数据源的负载。
    
-2. 当 `enable_func_pushdown` 设置为true,会将 where 之后的函数条件也下推到外部数据源,目前仅支持 MySQL,如遇到 
MySQL 不支持的函数,可以将此参数设置为 false。
+2. 当 `enable_func_pushdown` 设置为true,会将 where 之后的函数条件也下推到外部数据源,目前仅支持 MySQL,如遇到 
MySQL 不支持的函数,可以将此参数设置为 false,目前 Doris 会自动识别部分 MySQL 不支持的函数进行下推条件过滤,可通过 explain 
sql 查看。

Review Comment:
   Better add unsupported function in document



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to