DRILL-1619: Fix running and output type for count aggregate function Raise an exception while performing aggregate functions on boolean data type
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/0f069bad Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/0f069bad Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/0f069bad Branch: refs/heads/master Commit: 0f069bad0bbbc1f4f83d9e6a7194654fc5803ff2 Parents: 61053a8 Author: Mehant Baid <meha...@gmail.com> Authored: Thu Oct 30 23:02:41 2014 -0700 Committer: Jinfeng Ni <j...@maprtech.com> Committed: Fri Nov 7 10:50:55 2014 -0800 ---------------------------------------------------------------------- .../src/main/codegen/data/AggrTypes1.tdd | 8 +- .../expr/fn/impl/AggregateErrorFunctions.java | 84 ++++++++++++++++++++ 2 files changed, 86 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0f069bad/exec/java-exec/src/main/codegen/data/AggrTypes1.tdd ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/data/AggrTypes1.tdd b/exec/java-exec/src/main/codegen/data/AggrTypes1.tdd index 5b4041c..45d30a2 100644 --- a/exec/java-exec/src/main/codegen/data/AggrTypes1.tdd +++ b/exec/java-exec/src/main/codegen/data/AggrTypes1.tdd @@ -48,10 +48,8 @@ ] }, {className: "Max", funcName: "max", types: [ - {inputType: "Bit", outputType: "Bit", runningType: "Bit", major: "Numeric"}, {inputType: "Int", outputType: "Int", runningType: "Int", major: "Numeric"}, {inputType: "BigInt", outputType: "BigInt", runningType: "BigInt", major: "Numeric"}, - {inputType: "NullableBit", outputType: "NullableBit", runningType: "Bit", major: "Numeric"}, {inputType: "NullableInt", outputType: "NullableInt", runningType: "Int", major: "Numeric"}, {inputType: "NullableBigInt", outputType: "NullableBigInt", runningType: "BigInt", major: "Numeric"}, {inputType: "Float4", outputType: "Float4", runningType: "Float4", major: "Numeric"}, @@ -79,10 +77,8 @@ ] }, {className: "Sum", funcName: "sum", types: [ - {inputType: "Bit", outputType: "Bit", runningType: "Bit", major: "Numeric"}, {inputType: "Int", outputType: "BigInt", runningType: "BigInt", major: "Numeric"}, {inputType: "BigInt", outputType: "BigInt", runningType: "BigInt", major: "Numeric"}, - {inputType: "NullableBit", outputType: "NullableBit", runningType: "Bit", major: "Numeric"}, {inputType: "NullableInt", outputType: "NullableBigInt", runningType: "BigInt", major: "Numeric"}, {inputType: "NullableBigInt", outputType: "NullableBigInt", runningType: "BigInt", major: "Numeric"}, {inputType: "Float4", outputType: "Float8", runningType: "Float8", major: "Numeric"}, @@ -98,10 +94,10 @@ ] }, {className: "Count", funcName: "count", types: [ - {inputType: "Bit", outputType: "Bit", runningType: "Bit", major: "Numeric"}, + {inputType: "Bit", outputType: "BigInt", runningType: "BigInt", major: "Numeric"}, {inputType: "Int", outputType: "BigInt", runningType: "BigInt", major: "Numeric"}, {inputType: "BigInt", outputType: "BigInt", runningType: "BigInt", major: "Numeric"}, - {inputType: "NullableBit", outputType: "Bit", runningType: "Bit", major: "Numeric"}, + {inputType: "NullableBit", outputType: "BigInt", runningType: "BigInt", major: "Numeric"}, {inputType: "NullableInt", outputType: "BigInt", runningType: "BigInt", major: "Numeric"}, {inputType: "NullableBigInt", outputType: "BigInt", runningType: "BigInt", major: "Numeric"}, {inputType: "Float4", outputType: "BigInt", runningType: "BigInt", major: "Numeric"}, http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0f069bad/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 new file mode 100644 index 0000000..48a6625 --- /dev/null +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/AggregateErrorFunctions.java @@ -0,0 +1,84 @@ +/** + * 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.expr.fn.impl; + +import org.apache.drill.exec.expr.DrillAggFunc; +import org.apache.drill.exec.expr.annotations.FunctionTemplate; +import org.apache.drill.exec.expr.annotations.Output; +import org.apache.drill.exec.expr.annotations.Param; +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.record.RecordBatch; + +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 BitAggregateErrorFunctions implements DrillAggFunc { + + @Param BitHolder in; + @Workspace BigIntHolder value; + @Output BigIntHolder out; + + public void setup(RecordBatch b) { + if (true) { + throw new RuntimeException("Only COUNT aggregate function supported for Boolean type"); + } + } + + @Override + public void add() { + } + + @Override + public void output() { + } + + @Override + public void reset() { + } + + } + + @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; + @Output BigIntHolder out; + + public void setup(RecordBatch b) { + if (true) { + throw new RuntimeException("Only COUNT aggregate function supported for Boolean type"); + } + } + + @Override + public void add() { + } + + @Override + public void output() { + } + + @Override + public void reset() { + } + } +}