You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ja...@apache.org on 2014/06/16 23:31:36 UTC

[27/32] git commit: DRILL-978: Consider output type when we cost matching FunctionCall to FunctionHolder

DRILL-978: Consider output type when we cost matching FunctionCall to FunctionHolder


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

Branch: refs/heads/master
Commit: 9e7b14a559e9361e7b6a43cd625571c0c3a72b2e
Parents: c8db346
Author: Mehant Baid <me...@gmail.com>
Authored: Thu Jun 12 18:09:57 2014 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Mon Jun 16 12:44:28 2014 -0700

----------------------------------------------------------------------
 .../org/apache/drill/exec/expr/fn/DrillFuncHolder.java    |  8 ++++++++
 .../org/apache/drill/exec/resolver/TypeCastRules.java     | 10 ++++++++++
 2 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/9e7b14a5/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java
index bbe76de..fd687af 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java
@@ -293,4 +293,12 @@ public abstract class DrillFuncHolder {
     }
 
   }
+
+  public boolean matchInputOutputType() {
+    return false;
+  }
+
+  public MajorType getReturnType() {
+    return returnValue.type;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/9e7b14a5/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/TypeCastRules.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/TypeCastRules.java b/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/TypeCastRules.java
index 5c5ff80..854342c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/TypeCastRules.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/TypeCastRules.java
@@ -794,6 +794,16 @@ public class TypeCastRules {
     // number of arguments that could implicitly casts using precedence map or didn't require casting at all
     int nCasts = 0;
 
+    // Check if the function holder requires the input type and output type to match
+    if (holder.matchInputOutputType() == true) {
+      MinorType outputType = holder.getReturnType(call.args).getMinorType();
+      for (int i = 0; i < holder.getParamCount(); i++) {
+        if (call.args.get(i).getMajorType().getMinorType() != outputType) {
+          return -1;
+        }
+      }
+    }
+
     for (int i = 0; i < holder.getParamCount(); i++) {
       MajorType argType = call.args.get(i).getMajorType();
       MajorType parmType = holder.getParmMajorType(i);