drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meh...@apache.org
Subject [1/5] drill git commit: DRILL-584: Prevent second level of implicit casts to be added in ExpressionTreeMaterializer
Date Thu, 18 Dec 2014 04:38:12 GMT
Repository: drill
Updated Branches:
  refs/heads/master e07c33213 -> 709e976d2


DRILL-584: Prevent second level of implicit casts to be added in ExpressionTreeMaterializer


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/f516a201
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/f516a201
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/f516a201

Branch: refs/heads/master
Commit: f516a2011fda6b38c2c75db16c08ab65e8569970
Parents: e07c332
Author: Mehant Baid <mehantr@gmail.com>
Authored: Wed Dec 3 17:22:48 2014 -0800
Committer: Mehant Baid <mehantr@gmail.com>
Committed: Wed Dec 17 18:52:00 2014 -0800

----------------------------------------------------------------------
 .../exec/expr/ExpressionTreeMaterializer.java   |  2 +-
 .../exec/resolver/ExactFunctionResolver.java    | 51 ++++++++++++++++++++
 .../exec/resolver/FunctionResolverFactory.java  |  5 ++
 3 files changed, 57 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/f516a201/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
index a2d5e10..0f40958 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
@@ -293,7 +293,7 @@ public class ExpressionTreeMaterializer {
       }
 
       FunctionCall castCall = new FunctionCall(castFuncName, castArgs, ExpressionPosition.UNKNOWN);
-      FunctionResolver resolver = FunctionResolverFactory.getResolver(castCall);
+      FunctionResolver resolver = FunctionResolverFactory.getExactResolver(castCall);
       DrillFuncHolder matchedCastFuncHolder = registry.findDrillFunction(resolver, castCall);
 
       if (matchedCastFuncHolder == null) {

http://git-wip-us.apache.org/repos/asf/drill/blob/f516a201/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/ExactFunctionResolver.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/ExactFunctionResolver.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/ExactFunctionResolver.java
new file mode 100644
index 0000000..ab6be33
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/ExactFunctionResolver.java
@@ -0,0 +1,51 @@
+/**
+ * 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.drill.exec.resolver;
+
+import org.apache.drill.common.expression.FunctionCall;
+import org.apache.drill.exec.expr.fn.DrillFuncHolder;
+
+import java.util.List;
+
+public class ExactFunctionResolver implements FunctionResolver {
+
+
+  /*
+   * This function resolves the input call to a func holder only if all
+   * the input argument types match exactly with the func holder arguments. This is used
when we
+   * are trying to inject an implicit cast and do not want to inject another implicit
+   * cast
+   */
+  @Override
+  public DrillFuncHolder getBestMatch(List<DrillFuncHolder> methods, FunctionCall call)
{
+
+    int currcost;
+
+    for (DrillFuncHolder h : methods) {
+
+      currcost = TypeCastRules.getCost(call, h);
+
+      // Return if we found a function that has an exact match with the input arguments
+      if (currcost  == 0){
+        return h;
+      }
+    }
+    // No match found
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/f516a201/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/FunctionResolverFactory.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/FunctionResolverFactory.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/FunctionResolverFactory.java
index 0205aef..b9070af 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/FunctionResolverFactory.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/FunctionResolverFactory.java
@@ -26,4 +26,9 @@ public class FunctionResolverFactory {
     return new DefaultFunctionResolver();
   }
 
+  public static FunctionResolver getExactResolver(FunctionCall call) {
+    return new ExactFunctionResolver();
+  }
+
+
 }


Mime
View raw message