Index: serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/StructTypeInfo.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/StructTypeInfo.java (revision 1200086) +++ serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/StructTypeInfo.java (working copy) @@ -30,7 +30,7 @@ * StructTypeInfo represents the TypeInfo of a struct. A struct contains one or * more fields each of which has a unique name and its own TypeInfo. Different * fields can have the same or different TypeInfo. - * + * * Always use the TypeInfoFactory to create new TypeInfo objects, instead of * directly creating an instance of this class. */ @@ -82,10 +82,8 @@ * For TypeInfoFactory use only. */ StructTypeInfo(List names, List typeInfos) { - allStructFieldNames = new ArrayList(); - allStructFieldNames.addAll(names); - allStructFieldTypeInfos = new ArrayList(); - allStructFieldTypeInfos.addAll(typeInfos); + allStructFieldNames = new ArrayList(names); + allStructFieldTypeInfos = new ArrayList(typeInfos); } @Override Index: ql/src/test/results/clientpositive/input49.q.out =================================================================== --- ql/src/test/results/clientpositive/input49.q.out (revision 0) +++ ql/src/test/results/clientpositive/input49.q.out (revision 0) @@ -0,0 +1,51 @@ +PREHOOK: query: create table intable (b boolean, d double, f float, i int, l bigint, s string, t tinyint) +PREHOOK: type: CREATETABLE +POSTHOOK: query: create table intable (b boolean, d double, f float, i int, l bigint, s string, t tinyint) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@intable +PREHOOK: query: insert overwrite table intable select 0, 29098519.0, 1410.0, 996, 40408519555, "test_string", 12 from src limit 1 +PREHOOK: type: QUERY +PREHOOK: Input: default@src +PREHOOK: Output: default@intable +POSTHOOK: query: insert overwrite table intable select 0, 29098519.0, 1410.0, 996, 40408519555, "test_string", 12 from src limit 1 +POSTHOOK: type: QUERY +POSTHOOK: Input: default@src +POSTHOOK: Output: default@intable +POSTHOOK: Lineage: intable.b EXPRESSION [] +POSTHOOK: Lineage: intable.d SIMPLE [] +POSTHOOK: Lineage: intable.f EXPRESSION [] +POSTHOOK: Lineage: intable.i SIMPLE [] +POSTHOOK: Lineage: intable.l SIMPLE [] +POSTHOOK: Lineage: intable.s SIMPLE [] +POSTHOOK: Lineage: intable.t EXPRESSION [] +PREHOOK: query: select * from intable where d in (29098519.0) and f in (1410.0) and i in (996) and l in (40408519555) and s in ('test_string') and t in (12) +PREHOOK: type: QUERY +PREHOOK: Input: default@intable +PREHOOK: Output: file:/tmp/rsurowka/hive_2011-11-09_18-54-33_568_1893553420015585903/-mr-10000 +POSTHOOK: query: select * from intable where d in (29098519.0) and f in (1410.0) and i in (996) and l in (40408519555) and s in ('test_string') and t in (12) +POSTHOOK: type: QUERY +POSTHOOK: Input: default@intable +POSTHOOK: Output: file:/tmp/rsurowka/hive_2011-11-09_18-54-33_568_1893553420015585903/-mr-10000 +POSTHOOK: Lineage: intable.b EXPRESSION [] +POSTHOOK: Lineage: intable.d SIMPLE [] +POSTHOOK: Lineage: intable.f EXPRESSION [] +POSTHOOK: Lineage: intable.i SIMPLE [] +POSTHOOK: Lineage: intable.l SIMPLE [] +POSTHOOK: Lineage: intable.s SIMPLE [] +POSTHOOK: Lineage: intable.t EXPRESSION [] +false 2.9098519E7 1410.0 996 40408519555 test_string 12 +PREHOOK: query: drop table intable +PREHOOK: type: DROPTABLE +PREHOOK: Input: default@intable +PREHOOK: Output: default@intable +POSTHOOK: query: drop table intable +POSTHOOK: type: DROPTABLE +POSTHOOK: Input: default@intable +POSTHOOK: Output: default@intable +POSTHOOK: Lineage: intable.b EXPRESSION [] +POSTHOOK: Lineage: intable.d SIMPLE [] +POSTHOOK: Lineage: intable.f EXPRESSION [] +POSTHOOK: Lineage: intable.i SIMPLE [] +POSTHOOK: Lineage: intable.l SIMPLE [] +POSTHOOK: Lineage: intable.s SIMPLE [] +POSTHOOK: Lineage: intable.t EXPRESSION [] Index: ql/src/test/queries/clientpositive/input49.q =================================================================== --- ql/src/test/queries/clientpositive/input49.q (revision 0) +++ ql/src/test/queries/clientpositive/input49.q (revision 0) @@ -0,0 +1,3 @@ +create table intable (b boolean, d double, f float, i int, l bigint, s string, t tinyint); +insert overwrite table intable select 0, 29098519.0, 1410.0, 996, 40408519555, "test_string", 12 from src limit 1; +select * from intable where d in (29098519.0) and f in (1410.0) and i in (996) and l in (40408519555) and s in ('test_string') and t in (12); Index: ql/src/java/org/apache/hadoop/hive/ql/exec/TableScanOperator.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/TableScanOperator.java (revision 1200086) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/TableScanOperator.java (working copy) @@ -36,9 +36,9 @@ import org.apache.hadoop.hive.ql.stats.StatsSetupConst; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.ObjectInspectorCopyOption; import org.apache.hadoop.hive.serde2.objectinspector.StructField; import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector; -import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.ObjectInspectorCopyOption; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.mapred.JobConf; @@ -71,8 +71,8 @@ /** * Other than gathering statistics for the ANALYZE command, the table scan operator * does not do anything special other than just forwarding the row. Since the table - * data is always read as part of the map-reduce framework by the mapper. But, this - * assumption is not true, i.e table data is not only read by the mapper, this + * data is always read as part of the map-reduce framework by the mapper. But, when this + * assumption stops to be true, i.e table data won't be only read by the mapper, this * operator will be enhanced to read the table. **/ @Override Index: ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFIn.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFIn.java (revision 1200086) +++ ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFIn.java (working copy) @@ -18,13 +18,20 @@ package org.apache.hadoop.hive.ql.udf.generic; +import java.util.HashSet; +import java.util.Set; + import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFUtils.ReturnObjectInspectorResolver; +import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; +import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; import org.apache.hadoop.io.BooleanWritable; @@ -50,9 +57,12 @@ public class GenericUDFIn extends GenericUDF { private ObjectInspector[] argumentOIs; + private Set constantInSet; + private boolean isInSetConstant = true; //are variables from IN(...) constant + BooleanWritable bw = new BooleanWritable(); - ReturnObjectInspectorResolver conversionHelper = null; + ReturnObjectInspectorResolver conversionHelper; ObjectInspector compareOI; @Override @@ -89,9 +99,37 @@ } compareOI = conversionHelper.get(); + checkIfInSetConstant(); + return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector; } + private void checkIfInSetConstant(){ + for (int i = 1; i < argumentOIs.length; ++i){ + if (!(argumentOIs[i] instanceof ConstantObjectInspector)){ + isInSetConstant = false; + return; + } + } + } + + // we start at index 1, since at 0 is the variable from table column + // (and those from IN(...) follow it) + private void prepareInSet(DeferredObject[] arguments) throws HiveException { + constantInSet = new HashSet(); + if (compareOI.getCategory().equals(ObjectInspector.Category.PRIMITIVE)) { + for (int i = 1; i < arguments.length; ++i) { + constantInSet.add(((PrimitiveObjectInspector) compareOI) + .getPrimitiveJavaObject(conversionHelper + .convertIfNecessary(arguments[i].get(), argumentOIs[i]))); + } + } else { + for (int i = 1; i < arguments.length; ++i) { + constantInSet.add(((ConstantObjectInspector) argumentOIs[i]).getWritableConstantValue()); + } + } + } + @Override public Object evaluate(DeferredObject[] arguments) throws HiveException { bw.set(false); @@ -100,21 +138,60 @@ return null; } - for (int i=1; i