Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill >> mail # dev >> [3/6] git commit: DRILL-259: Implicit cast precedence work


Copy link to this message
-
[3/6] git commit: DRILL-259: Implicit cast precedence work
DRILL-259: Implicit cast precedence work

Includes following changes:
Created resolvers and mini precedence map

changed operator resolution by adding getCost method

Updated precedence map for operator resolution - typecast

Modified DrillFuncHolder:getCost() to allow null arguments type in cast

Cast Null arg precedence

Added type cast rules : isCastable()

Added type cast rules : isCastable()
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/36945428
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/36945428
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/36945428

Branch: refs/heads/master
Commit: 369454281caebc3947f8364bf48738b488b90895
Parents: 931b641
Author: Yash <[EMAIL PROTECTED]>
Authored: Wed Nov 13 12:15:53 2013 +0530
Committer: Jacques Nadeau <[EMAIL PROTECTED]>
Committed: Tue Jan 14 08:40:41 2014 -0800

----------------------------------------------------------------------
 .../common/expression/fn/MathFunctions.java     |   2 +-
 .../org/apache/drill/exec/ExecConstants.java    |   2 +
 .../drill/exec/expr/fn/DrillFuncHolder.java     |  49 ++
 .../expr/fn/FunctionImplementationRegistry.java |  19 +-
 .../drill/exec/expr/fn/impl/MathFunctions.java  |  31 ++
 .../exec/resolver/DefaultFunctionResolver.java  |  22 +
 .../drill/exec/resolver/FunctionResolver.java   |  12 +
 .../exec/resolver/FunctionResolverFactory.java  |  18 +
 .../exec/resolver/OperatorFunctionResolver.java |  52 +++
 .../exec/resolver/ResolverTypePrecedence.java   |  41 ++
 .../drill/exec/resolver/TypeCastRules.java      | 466 +++++++++++++++++++
 .../exec/resolver/UDFFunctionResolver.java      |  17 +
 exec/ref/src/test/resources/simple_plan.json    | 131 +++---
 pom.xml                                         |  10 +-
 sqlline                                         |   1 +
 15 files changed, 807 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/36945428/common/src/main/java/org/apache/drill/common/expression/fn/MathFunctions.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/expression/fn/MathFunctions.java b/common/src/main/java/org/apache/drill/common/expression/fn/MathFunctions.java
index ee3a099..12b821d 100644
--- a/common/src/main/java/org/apache/drill/common/expression/fn/MathFunctions.java
+++ b/common/src/main/java/org/apache/drill/common/expression/fn/MathFunctions.java
@@ -30,7 +30,7 @@ public class MathFunctions implements CallProvider{
   @Override
   public FunctionDefinition[] getFunctionDefintions() {
     return new FunctionDefinition[]{
-        FunctionDefinition.operator("add", new ArgumentValidators.NumericTypeAllowed(1, Integer.MAX_VALUE, true), new OutputTypeDeterminer.SameAsAnySoft(), "+"),
+        FunctionDefinition.operator("add", new ArgumentValidators.NumericTypeAllowed(1, Integer.MAX_VALUE, false), new OutputTypeDeterminer.SameAsAnySoft(), "+"),
         FunctionDefinition.operator("subtract", new ArgumentValidators.NumericTypeAllowed(1, Integer.MAX_VALUE, true), new OutputTypeDeterminer.SameAsAnySoft(), "-"),
         FunctionDefinition.operator("divide", new ArgumentValidators.NumericTypeAllowed(1, Integer.MAX_VALUE, true), new OutputTypeDeterminer.SameAsAnySoft(), "/"),
         FunctionDefinition.operator("multiply", new ArgumentValidators.NumericTypeAllowed(1, Integer.MAX_VALUE, true), new OutputTypeDeterminer.SameAsAnySoft(), "*"),

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/36945428/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
index 5336c0e..436d820 100644
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
@@ -50,4 +50,6 @@ public interface ExecConstants {
   public static final String SPOOLING_BUFFER_IMPL = "drill.exec.spooling.impl";
   public static final String SPOOLING_BUFFER_DELETE = "drill.exec.spooling.delete";
   public static final String SPOOLING_BUFFER_MEMORY = "drill.exec.spooling.size";
+  public static final String NULL_EXPRESSION = "NULLEXPRESSION";
+  
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/36945428/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 e6ef802..d2b7e47 100644
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java
@@ -24,12 +24,16 @@ import org.apache.drill.common.expression.FunctionCall;
 import org.apache.drill.common.expression.LogicalExpression;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.expr.CodeGenerator;
 import org.apache.drill.exec.expr.CodeGenerator.BlockType;
 import org.apache.drill.exec.expr.CodeGenerator.HoldingContainer;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.FunctionScope;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
+import org.apache.drill.exec.record.NullExpression;
+import org.apache.drill.exec.resolver.ResolverTypePrecedence;
+import org.apache.drill.exec.resolver.TypeCastRules;
 
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
@@ -149,6 +153,51 @@ public abstract class DrillFuncHolder {
     return true;
   }
  
+  
+  public int getCost(FunctionCall call){