You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/08/26 15:22:01 UTC

[GitHub] [incubator-doris] morningman commented on a change in pull request #6507: 【Bug】Some functions of doris push down mysql to run abnormally

morningman commented on a change in pull request #6507:
URL: https://github.com/apache/incubator-doris/pull/6507#discussion_r696731255



##########
File path: fe/fe-core/src/main/java/org/apache/doris/planner/MysqlScanNode.java
##########
@@ -131,7 +131,11 @@ private void createMySQLFilters(Analyzer analyzer) {
         }
         ArrayList<Expr> mysqlConjuncts = Expr.cloneList(conjuncts, sMap);
         for (Expr p : mysqlConjuncts) {
-            filters.add(p.toMySql());
+            if (Config.enable_external_database_function_push_down) {
+                FunctionMappingHelper.mappingEngineFunction(p, "mysql");

Review comment:
       "mysql" should be defined as a const value or enum

##########
File path: fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java
##########
@@ -169,7 +155,8 @@ private void createOdbcFilters(Analyzer analyzer) {
         }
         ArrayList<Expr> odbcConjuncts = Expr.cloneList(conjuncts, sMap);
         for (Expr p : odbcConjuncts) {
-            if (shouldPushDownConjunct(odbcType, p)) {
+            if (Config.enable_external_database_function_push_down) {

Review comment:
       This better not be a `config`, because user may visit mysql and oracle in one Doris cluster.
   And what if user query both mysql and oracle in one SQL?
   This is a bit complicate, I have no idea how to solve it yet.

##########
File path: fe/fe-core/src/main/java/org/apache/doris/planner/FunctionMappingHelper.java
##########
@@ -0,0 +1,88 @@
+// 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;
+
+import com.google.common.collect.Maps;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Map;
+import org.apache.doris.analysis.Expr;
+import org.apache.doris.analysis.FunctionCallExpr;
+import org.apache.doris.analysis.FunctionName;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class FunctionMappingHelper {
+    private static final Logger LOG = LogManager.getLogger(FunctionMappingHelper.class);
+
+    public final static Map<String, Map<String, String>> EXTERNAL_DATABASE_FUNCTION_MAPPING = Maps.newTreeMap();
+    public final static Map<String, String> MYSQL_MAPPING_FUNCTION = Maps.newTreeMap();
+    public final static Map<String, String> ORACLE_MAPPING_FUNCTION = Maps.newTreeMap();
+    public final static Map<String, String> SQLSERVER_MAPPING_FUNCTION = Maps.newTreeMap();
+    public final static Map<String, String> POSTGRESQL_MAPPING_FUNCTION = Maps.newTreeMap();
+
+    static {
+        // Add mapping function.
+        addFunctionMapping("mysql","get_json_string", "json_extract");
+    }
+
+    public static void addFunctionMapping(String databaseType, String sourceFunction, String targetFunction) {

Review comment:
       databaseType: use enum instead of string




-- 
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-unsubscribe@doris.apache.org

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



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