diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java index fc0256c..53d5b8f 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java @@ -208,6 +208,8 @@ import org.apache.hadoop.hive.ql.udf.generic.GenericUDFUnixTimeStamp; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFWhen; import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; +import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFMedianResolver; +import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFModeResolver; import org.apache.hadoop.hive.ql.udf.generic.GenericUDTFExplode; import org.apache.hadoop.hive.ql.udf.generic.GenericUDTFInline; import org.apache.hadoop.hive.ql.udf.generic.GenericUDTFJSONTuple; @@ -411,7 +413,8 @@ // Aggregate functions registerGenericUDAF("max", new GenericUDAFMax()); registerGenericUDAF("min", new GenericUDAFMin()); - + registerGenericUDAF("median",new GenericUDAFMedianResolver()); + registerGenericUDAF("mode",new GenericUDAFModeResolver()); registerGenericUDAF("sum", new GenericUDAFSum()); registerGenericUDAF("count", new GenericUDAFCount()); registerGenericUDAF("avg", new GenericUDAFAverage()); diff --git ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFMedianResolver.java ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFMedianResolver.java new file mode 100644 index 0000000..2a3c718 --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFMedianResolver.java @@ -0,0 +1,157 @@ +/** + * 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.hadoop.hive.ql.udf.generic; + +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hive.ql.exec.Description; +import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; +import org.apache.hadoop.hive.ql.metadata.HiveException; +import org.apache.hadoop.hive.ql.parse.SemanticException; +import org.apache.hadoop.hive.ql.udf.generic.AbstractGenericUDAFResolver; +import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; +import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; +import org.apache.hadoop.hive.serde2.io.DoubleWritable; +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory; +import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory; +import org.apache.hadoop.hive.serde2.objectinspector.StandardListObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; +import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; +import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo; + +/** + * Computes the median of a given numeric data set for very large numbers of + * rows UDAF might run out of memory. The input is any numeric type supported by + * hive The output, corresponding to the input, is a single value corresponding + * to the median. + */ +@Description(name = "median", value = "_FUNC_(x) - returns the median of a data set\n" + + "Example\n" + "> SELECT median(val) FROM somedata;\n") +public class GenericUDAFMedianResolver extends AbstractGenericUDAFResolver { + + static final Log LOG = LogFactory.getLog(GenericUDAFMedianResolver.class.getName()); + + + @Override + public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters)throws SemanticException { + if (parameters.length != 1) { + throw new UDFArgumentTypeException(parameters.length - 1, + "Please specify only one numeric argument"); + } + + if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) { + throw new UDFArgumentTypeException(0, + "Only numeric type argument is accepted but " + + parameters[0].getTypeName() + + " was passed as parameter "); + } + + if (parameters[0].getTypeName().equalsIgnoreCase( + PrimitiveCategory.STRING.name()) + || parameters[0].getTypeName().equalsIgnoreCase( + PrimitiveCategory.BOOLEAN.name())) { + throw new UDFArgumentTypeException(0, + "Only numeric type argument is accepted but " + + parameters[0].getTypeName() + + " was passed as parameter "); + } + return new GenericUDAFModeEvaluator(); + } + + public static class GenericUDAFModeEvaluator extends GenericUDAFEvaluator { + protected PrimitiveObjectInspector inputOI; + protected StandardListObjectInspector loi; + + static class ModeAggBuf implements AggregationBuffer { + SimpleNumericHistogram histogram; + }; + + @Override + public AggregationBuffer getNewAggregationBuffer() throws HiveException { + ModeAggBuf modeAgg = new ModeAggBuf(); + modeAgg.histogram = new SimpleNumericHistogram(); + reset(modeAgg); + return modeAgg; + } + + @Override + public void reset(AggregationBuffer agg) throws HiveException { + ModeAggBuf modeAgg = (ModeAggBuf) agg; + modeAgg.histogram.reset(); + modeAgg.histogram.allocate(); + } + + @Override + public ObjectInspector init(Mode m, ObjectInspector[] parameters) + throws HiveException { + super.init(m, parameters); + // init input object inspectors + if (m == Mode.PARTIAL1 || m == Mode.COMPLETE) { + inputOI = (PrimitiveObjectInspector) parameters[0]; + } else { + loi = (StandardListObjectInspector) parameters[0]; + } + if (m == Mode.PARTIAL1 || m == Mode.PARTIAL2) { + return ObjectInspectorFactory + .getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector); + } else { + return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector; + } + } + + @Override + public void iterate(AggregationBuffer agg, Object[] parameters) + throws HiveException { + assert (parameters.length == 1); + if (parameters[0] == null) { + return; + } + ModeAggBuf myagg = (ModeAggBuf) agg; + double v = PrimitiveObjectInspectorUtils.getDouble(parameters[0], + inputOI); + myagg.histogram.add(v); + } + + @Override + public Object terminatePartial(AggregationBuffer agg) + throws HiveException { + return ((ModeAggBuf) agg).histogram.serialize(); + } + + @Override + public void merge(AggregationBuffer agg, Object partial) + throws HiveException { + if (partial == null) { + return; + } + ModeAggBuf myagg = (ModeAggBuf) agg; + List partialHistogram = (List) loi + .getList(partial); + myagg.histogram.merge(partialHistogram); + } + + @Override + public Object terminate(AggregationBuffer agg) throws HiveException { + return ((ModeAggBuf) agg).histogram.median(); + } + } +} \ No newline at end of file diff --git ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFModeResolver.java ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFModeResolver.java new file mode 100644 index 0000000..29e6dcd --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFModeResolver.java @@ -0,0 +1,152 @@ +/** + * 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.hadoop.hive.ql.udf.generic; + +import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hive.ql.exec.Description; +import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; +import org.apache.hadoop.hive.ql.metadata.HiveException; +import org.apache.hadoop.hive.ql.parse.SemanticException; +import org.apache.hadoop.hive.ql.udf.generic.AbstractGenericUDAFResolver; +import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; +import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; +import org.apache.hadoop.hive.serde2.io.DoubleWritable; +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory; +import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory; +import org.apache.hadoop.hive.serde2.objectinspector.StandardListObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; +import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; +import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo; + +/** + * Computes the mode of a given numeric data set for very large numbers of rows + * UDAF might run out of memory. The input is any numeric type supported by hive + * The output, corresponding to the input, is either an single value or an + * arraylist of values corresponding to the mode. + */ +@Description(name = "mode", value = "_FUNC_(x) - returns the mode of a data set\n" + + "Example\n" + "> SELECT mode(val) FROM somedata;\n") +public class GenericUDAFModeResolver extends AbstractGenericUDAFResolver { + + static final Log LOG = LogFactory.getLog(GenericUDAFModeResolver.class.getName()); + + + @Override + public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) + throws SemanticException { + if (parameters.length != 1) { + throw new UDFArgumentTypeException(parameters.length - 1, + "Please specify only one numeric argument"); + } + if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) { + throw new UDFArgumentTypeException(0, + "Only numeric type argument is accepted but " + + parameters[0].getTypeName() + + " was passed as parameter "); + } + if (parameters[0].getTypeName().equalsIgnoreCase( + PrimitiveCategory.STRING.name()) + || parameters[0].getTypeName().equalsIgnoreCase( + PrimitiveCategory.BOOLEAN.name())) { + throw new UDFArgumentTypeException(0, + "Only numeric type argument is accepted but " + + parameters[0].getTypeName() + + " was passed as parameter "); + } + return new GenericUDAFModeEvaluator(); + } + + public static class GenericUDAFModeEvaluator extends GenericUDAFEvaluator { + protected PrimitiveObjectInspector inputOI; + protected StandardListObjectInspector loi; + + static class ModeAggBuf implements AggregationBuffer { + SimpleNumericHistogram histogram; + }; + + @Override + public AggregationBuffer getNewAggregationBuffer() throws HiveException { + ModeAggBuf modeAgg = new ModeAggBuf(); + modeAgg.histogram = new SimpleNumericHistogram(); + reset(modeAgg); + return modeAgg; + } + + @Override + public void reset(AggregationBuffer agg) throws HiveException { + ModeAggBuf modeAgg = (ModeAggBuf) agg; + modeAgg.histogram.reset(); + modeAgg.histogram.allocate(); + } + + @Override + public ObjectInspector init(Mode m, ObjectInspector[] parameters) + throws HiveException { + super.init(m, parameters); + // init input object inspectors + if (m == Mode.PARTIAL1 || m == Mode.COMPLETE) { + inputOI = (PrimitiveObjectInspector) parameters[0]; + } else { + loi = (StandardListObjectInspector) parameters[0]; + } + return ObjectInspectorFactory + .getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector); + + } + + @Override + public void iterate(AggregationBuffer agg, Object[] parameters) + throws HiveException { + assert (parameters.length == 1); + if (parameters[0] == null) { + return; + } + ModeAggBuf myagg = (ModeAggBuf) agg; + double v = PrimitiveObjectInspectorUtils.getDouble(parameters[0], + inputOI); + myagg.histogram.add(v); + } + + @Override + public Object terminatePartial(AggregationBuffer agg) + throws HiveException { + return ((ModeAggBuf) agg).histogram.serialize(); + } + + @Override + public void merge(AggregationBuffer agg, Object partial) + throws HiveException { + if (partial == null) { + return; + } + ModeAggBuf myagg = (ModeAggBuf) agg; + List partialHistogram = (List) loi + .getList(partial); + myagg.histogram.merge(partialHistogram); + } + + @Override + public Object terminate(AggregationBuffer agg) throws HiveException { + return ((ModeAggBuf) agg).histogram.mode(); + } + } +} \ No newline at end of file diff --git ql/src/java/org/apache/hadoop/hive/ql/udf/generic/SimpleNumericHistogram.java ql/src/java/org/apache/hadoop/hive/ql/udf/generic/SimpleNumericHistogram.java new file mode 100644 index 0000000..08ff9cf --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/udf/generic/SimpleNumericHistogram.java @@ -0,0 +1,246 @@ +/** + * 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.hadoop.hive.ql.udf.generic; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.apache.hadoop.hive.serde2.io.DoubleWritable; + +/** + * A Simple Histogram class, adapted from + * org.apache.hadoop.hive.ql.udf.generic.NumericHistogram + */ +public class SimpleNumericHistogram { + /** + * The Coord class defines a histogram bin, which is just an (x,y) pair. + */ + static class Coord implements Comparable { + double x; + double y; + + public int compareTo(Object other) { + Coord o = (Coord) other; + if (x < o.x) { + return -1; + } + if (x > o.x) { + return 1; + } + return 0; + } + }; + + private ArrayList bins; + + /** + * Creates a new histogram object. Note that the allocate() method must be + * called before the histogram can be used. + */ + public SimpleNumericHistogram() { + bins = null; + } + + /** + * Resets a histogram object to its initial state. + */ + public void reset() { + bins = null; + } + + /** + * Returns true if this histogram object has been initialized by calling + * allocate(). + */ + public boolean isReady() { + return bins.size() != 0; + } + + /** + * Returns a particular histogram bin. + */ + public Coord getBin(int b) { + return bins.get(b); + } + + /** + * Allocates bins + */ + public void allocate() { + bins = new ArrayList(); + } + + /** + * Takes a serialized histogram created by the serialize() method and merges + * it with the current histogram object. + * + * @param other + * A serialized histogram created by the serialize() method + * @see #merge + */ + + public void merge(List other) { + if (other == null) { + return; + } + + Coord bin; + for (int i = 0; i < other.size(); i += 2) { + bin = new Coord(); + bin.x = other.get(i).get(); + bin.y = other.get(i + 1).get(); + bins.add(bin); + } + Collections.sort(bins); + int sizeOfBins = bins.size() - 1; + Coord currentCoord; + Coord nextCoord; + for (int i = 0; i < sizeOfBins; i++) { + currentCoord = bins.get(i); + nextCoord = bins.get(i + 1); + if (currentCoord.x == nextCoord.x) { + currentCoord.y = currentCoord.y + nextCoord.y; + bins.remove(i + 1); + } + } + } + + /** + * Adds a new data point to the histogram approximation. Make sure you have + * + * @param v + * The data point to add to the histogram. + */ + public void add(double v) { + // Binary search to find the closest bucket that v should go into. + // 'bin' should be interpreted as the bin to shift right in order to + // accomodate v. As a result, bin is in the range [0,N], where N means + // that the + // value v is + // greater than all the N bins currently in the histogram. It is also + // possible that + // a bucket centered at 'v' already exists, so this must be checked in + // the next step. + int bin = 0; + int sizeOfBins = bins.size(); + for (int l = 0, r = sizeOfBins; l < r;) { + bin = (l + r) / 2; + if (bins.get(bin).x > v) { + r = bin; + } else { + if (bins.get(bin).x < v) { + l = ++bin; + } else { + break; // break loop on equal comparator + } + } + } + // If we found an exact bin match for value v, then just increment that + // bin's count. Otherwise, we need to insert a new bin + if (bin < sizeOfBins && bins.get(bin).x == v) { + bins.get(bin).y++; + } else { + Coord newBin = new Coord(); + newBin.x = v; + newBin.y = 1; + bins.add(bin, newBin); + } + } + + /** + * In preparation for a Hive merge() call, serializes the current histogram + * object into an ArrayList of DoubleWritable objects. This list is + * deserialized and merged by the merge method. + * + * @return An ArrayList of Hadoop DoubleWritable objects that represents the + * current histogram. + * @see #merge + */ + public ArrayList serialize() { + ArrayList result = new ArrayList(); + // Return a single ArrayList representing bins (x,y) pairs at + // consecutive locations + int sizeOfBins = bins.size(); + if (bins != null) { + for (int i = 0; i < sizeOfBins; i++) { + result.add(new DoubleWritable(bins.get(i).x)); + result.add(new DoubleWritable(bins.get(i).y)); + } + } + return result; + } + + /** + * Method that computes the mode of the dataset. Returns the maximum + * repeating value(s) in the current histogram represented by bins + * + * @return An ArrayList of Hadoop DoubleWritable objects that represents the + * mode of the current histogram + */ + public ArrayList mode() { + double maxValue = 0; + ArrayList modes = new ArrayList(); + int sizeOfBins = bins.size(); + Coord currentCoord; + for (int i = 0; i < sizeOfBins; i++) { + currentCoord = bins.get(i); + if (currentCoord.y > maxValue) { + modes.clear(); + modes.add(new DoubleWritable(currentCoord.x)); + maxValue = currentCoord.y; + } else if (maxValue == currentCoord.y) { + modes.add(new DoubleWritable(currentCoord.x)); + } + } + return modes; + } + + /** + * Method that computes the median of the dataset. Returns the middle value + * in the current histogram represented by bins + * + * @return A Hadoop DoubleWritable objects that represents the median of the + * current histogram + */ + public DoubleWritable median() { + double totalCount = 0; + DoubleWritable median = new DoubleWritable(0); + double aggregateCount = 0; + int sizeOfBins = bins.size(); + for (int i = 0; i < sizeOfBins; i++) { + totalCount += bins.get(i).y; + } + double medianPos = totalCount / 2; + for (int i = 0; i < sizeOfBins; i++) { + aggregateCount += bins.get(i).y; + if (aggregateCount == medianPos) { + if (medianPos + 1 <= aggregateCount) { + median.set(bins.get(i).x); + break; + } else { + median.set((bins.get(i).x + bins.get(i + 1).x) / 2); + break; + } + } else if (aggregateCount > medianPos) { + median.set(bins.get(i).x); + break; + } + } + return median; + } +} \ No newline at end of file diff --git ql/src/test/queries/clientpositive/median.q ql/src/test/queries/clientpositive/median.q new file mode 100644 index 0000000..78be8d4 --- /dev/null +++ ql/src/test/queries/clientpositive/median.q @@ -0,0 +1,8 @@ +CREATE TABLE testmedianandmode(column1 INT) +ROW FORMAT DELIMITED LINES TERMINATED BY '\n' +STORED AS TEXTFILE; +LOAD DATA LOCAL INPATH '/home/691623/Desktop/input.txt' OVERWRITE +INTO TABLE testmedianandmode; +DESCRIBE FUNCTION median; +DESCRIBE FUNCTION EXTENDED median; +SELECT median(column1) FROM testmedianandmode; diff --git ql/src/test/queries/clientpositive/mode.q ql/src/test/queries/clientpositive/mode.q new file mode 100644 index 0000000..56c3276 --- /dev/null +++ ql/src/test/queries/clientpositive/mode.q @@ -0,0 +1,8 @@ +CREATE TABLE testmedianandmode(column1 INT) +ROW FORMAT DELIMITED LINES TERMINATED BY '\n' +STORED AS TEXTFILE; +LOAD DATA LOCAL INPATH '/home/691623/Desktop/input.txt' OVERWRITE +INTO TABLE testmedianandmode; +DESCRIBE FUNCTION mode; +DESCRIBE FUNCTION EXTENDED mode; +SELECT mode(column1) FROM testmedianandmode; diff --git ql/src/test/results/clientpositive/median.q.out ql/src/test/results/clientpositive/median.q.out new file mode 100644 index 0000000..5ac3a52 --- /dev/null +++ ql/src/test/results/clientpositive/median.q.out @@ -0,0 +1,42 @@ +PREHOOK: query: CREATE TABLE testmedianandmode(column1 INT) +ROW FORMAT DELIMITED LINES TERMINATED BY '\n' +STORED AS TEXTFILE +PREHOOK: type: CREATETABLE +POSTHOOK: query: CREATE TABLE testmedianandmode(column1 INT) +ROW FORMAT DELIMITED LINES TERMINATED BY '\n' +STORED AS TEXTFILE +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@testmedianandmode +PREHOOK: query: LOAD DATA LOCAL INPATH '/home/691623/Desktop/input.txt' OVERWRITE +INTO TABLE testmedianandmode +PREHOOK: type: LOAD +PREHOOK: Output: default@testmedianandmode +POSTHOOK: query: LOAD DATA LOCAL INPATH '/home/691623/Desktop/input.txt' OVERWRITE +INTO TABLE testmedianandmode +POSTHOOK: type: LOAD +POSTHOOK: Output: default@testmedianandmode +PREHOOK: query: DESCRIBE FUNCTION median +PREHOOK: type: DESCFUNCTION +POSTHOOK: query: DESCRIBE FUNCTION median +POSTHOOK: type: DESCFUNCTION +median(x) - returns the median of a data set +Example +> SELECT median(val) FROM somedata; + +PREHOOK: query: DESCRIBE FUNCTION EXTENDED median +PREHOOK: type: DESCFUNCTION +POSTHOOK: query: DESCRIBE FUNCTION EXTENDED median +POSTHOOK: type: DESCFUNCTION +median(x) - returns the median of a data set +Example +> SELECT median(val) FROM somedata; + +PREHOOK: query: SELECT median(column1) FROM testmedianandmode +PREHOOK: type: QUERY +PREHOOK: Input: default@testmedianandmode +#### A masked pattern was here #### +POSTHOOK: query: SELECT median(column1) FROM testmedianandmode +POSTHOOK: type: QUERY +POSTHOOK: Input: default@testmedianandmode +#### A masked pattern was here #### +4.0 diff --git ql/src/test/results/clientpositive/mode.q.out ql/src/test/results/clientpositive/mode.q.out new file mode 100644 index 0000000..96e1f3b --- /dev/null +++ ql/src/test/results/clientpositive/mode.q.out @@ -0,0 +1,42 @@ +PREHOOK: query: CREATE TABLE testmedianandmode(column1 INT) +ROW FORMAT DELIMITED LINES TERMINATED BY '\n' +STORED AS TEXTFILE +PREHOOK: type: CREATETABLE +POSTHOOK: query: CREATE TABLE testmedianandmode(column1 INT) +ROW FORMAT DELIMITED LINES TERMINATED BY '\n' +STORED AS TEXTFILE +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@testmedianandmode +PREHOOK: query: LOAD DATA LOCAL INPATH '/home/691623/Desktop/input.txt' OVERWRITE +INTO TABLE testmedianandmode +PREHOOK: type: LOAD +PREHOOK: Output: default@testmedianandmode +POSTHOOK: query: LOAD DATA LOCAL INPATH '/home/691623/Desktop/input.txt' OVERWRITE +INTO TABLE testmedianandmode +POSTHOOK: type: LOAD +POSTHOOK: Output: default@testmedianandmode +PREHOOK: query: DESCRIBE FUNCTION mode +PREHOOK: type: DESCFUNCTION +POSTHOOK: query: DESCRIBE FUNCTION mode +POSTHOOK: type: DESCFUNCTION +mode(x) - returns the mode of a data set +Example +> SELECT mode(val) FROM somedata; + +PREHOOK: query: DESCRIBE FUNCTION EXTENDED mode +PREHOOK: type: DESCFUNCTION +POSTHOOK: query: DESCRIBE FUNCTION EXTENDED mode +POSTHOOK: type: DESCFUNCTION +mode(x) - returns the mode of a data set +Example +> SELECT mode(val) FROM somedata; + +PREHOOK: query: SELECT mode(column1) FROM testmedianandmode +PREHOOK: type: QUERY +PREHOOK: Input: default@testmedianandmode +#### A masked pattern was here #### +POSTHOOK: query: SELECT mode(column1) FROM testmedianandmode +POSTHOOK: type: QUERY +POSTHOOK: Input: default@testmedianandmode +#### A masked pattern was here #### +[4.0]