drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meh...@apache.org
Subject [3/3] drill git commit: DRILL-3245: Fix error message for unsupported aggregate functions on varchar data type
Date Thu, 04 Jun 2015 18:48:38 GMT
DRILL-3245: Fix error message for unsupported aggregate functions on varchar data type


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

Branch: refs/heads/master
Commit: 287f52db0bd0125e0ad1b3408f22775224ee9494
Parents: 09e46df
Author: Mehant Baid <mehantr@gmail.com>
Authored: Wed Jun 3 15:12:30 2015 -0700
Committer: Mehant Baid <mehantr@gmail.com>
Committed: Wed Jun 3 15:12:30 2015 -0700

----------------------------------------------------------------------
 .../expr/fn/impl/AggregateErrorFunctions.java   | 87 ++++++++++++++++++--
 1 file changed, 82 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/287f52db/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/AggregateErrorFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/AggregateErrorFunctions.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/AggregateErrorFunctions.java
index a95a1c3..8161a43 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/AggregateErrorFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/AggregateErrorFunctions.java
@@ -25,10 +25,18 @@ import org.apache.drill.exec.expr.annotations.Workspace;
 import org.apache.drill.exec.expr.holders.BigIntHolder;
 import org.apache.drill.exec.expr.holders.BitHolder;
 import org.apache.drill.exec.expr.holders.NullableBitHolder;
+import org.apache.drill.exec.expr.holders.NullableVarCharHolder;
+import org.apache.drill.exec.expr.holders.VarCharHolder;
 
+/*
+ * TODO: For a handful of functions this approach of using function binding to detect that
it is an invalid function is okay.
+ * However moving forward we should introduce a validation phase after we learn the data
types and before we try
+ * to perform function resolution. Otherwise with implicit cast we will try to bind to an
existing function.
+ */
 public class AggregateErrorFunctions {
 
-  @FunctionTemplate(names = {"sum", "max", "avg", "stddev_pop", "stddev_samp", "stddev",
"var_pop", "var_samp", "variance"}, scope = FunctionTemplate.FunctionScope.POINT_AGGREGATE)
+  @FunctionTemplate(names = {"sum", "max", "avg", "stddev_pop", "stddev_samp", "stddev",
"var_pop",
+      "var_samp", "variance"}, scope = FunctionTemplate.FunctionScope.POINT_AGGREGATE)
   public static class BitAggregateErrorFunctions implements DrillAggFunc {
 
     @Param BitHolder in;
@@ -37,7 +45,10 @@ public class AggregateErrorFunctions {
 
     public void setup() {
       if (true) {
-        throw new RuntimeException("Only COUNT aggregate function supported for Boolean type");
+        throw org.apache.drill.common.exceptions.UserException
+            .unsupportedError()
+            .message("Only COUNT aggregate function supported for Boolean type")
+            .build();
       }
     }
 
@@ -55,8 +66,9 @@ public class AggregateErrorFunctions {
 
   }
 
-  @FunctionTemplate(names = {"sum", "max", "avg", "stddev_pop", "stddev_samp", "stddev",
"var_pop", "var_samp", "variance"}, scope = FunctionTemplate.FunctionScope.POINT_AGGREGATE)
-  public static class NullableBitAggregateErrorFunctions implements DrillAggFunc{
+  @FunctionTemplate(names = {"sum", "max", "avg", "stddev_pop", "stddev_samp", "stddev",
"var_pop",
+      "var_samp", "variance"}, scope = FunctionTemplate.FunctionScope.POINT_AGGREGATE)
+  public static class NullableBitAggregateErrorFunctions implements DrillAggFunc {
 
     @Param NullableBitHolder in;
     @Workspace BigIntHolder value;
@@ -64,7 +76,72 @@ public class AggregateErrorFunctions {
 
     public void setup() {
       if (true) {
-        throw new RuntimeException("Only COUNT aggregate function supported for Boolean type");
+        throw org.apache.drill.common.exceptions.UserException
+            .unsupportedError()
+            .message("Only COUNT aggregate function supported for Boolean type")
+            .build();
+      }
+    }
+
+    @Override
+    public void add() {
+    }
+
+    @Override
+    public void output() {
+    }
+
+    @Override
+    public void reset() {
+    }
+  }
+
+
+  @FunctionTemplate(names = {"sum", "avg", "stddev_pop", "stddev_samp", "stddev", "var_pop",
"var_samp", "variance"},
+      scope = FunctionTemplate.FunctionScope.POINT_AGGREGATE)
+  public static class VarCharAggregateErrorFunctions implements DrillAggFunc {
+
+    @Param VarCharHolder in;
+    @Workspace BigIntHolder value;
+    @Output BigIntHolder out;
+
+    public void setup() {
+      if (true) {
+        throw org.apache.drill.common.exceptions.UserException
+            .unsupportedError()
+            .message("Only COUNT, MIN and MAX aggregate functions supported for VarChar type")
+            .build();
+      }
+    }
+
+    @Override
+    public void add() {
+    }
+
+    @Override
+    public void output() {
+    }
+
+    @Override
+    public void reset() {
+    }
+
+  }
+
+  @FunctionTemplate(names = {"sum", "avg", "stddev_pop", "stddev_samp", "stddev", "var_pop",
"var_samp", "variance"},
+      scope = FunctionTemplate.FunctionScope.POINT_AGGREGATE)
+  public static class NullableVarCharAggregateErrorFunctions implements DrillAggFunc {
+
+    @Param NullableVarCharHolder in;
+    @Workspace BigIntHolder value;
+    @Output BigIntHolder out;
+
+    public void setup() {
+      if (true) {
+        throw org.apache.drill.common.exceptions.UserException
+            .unsupportedError()
+            .message("Only COUNT, MIN and MAX aggregate functions supported for VarChar type")
+            .build();
       }
     }
 


Mime
View raw message