Search in sources :

Example 41 with ConstantObjectInspector

use of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector in project hive by apache.

the class TypeCheckProcFactory method toExprNodeDesc.

static ExprNodeDesc toExprNodeDesc(ColumnInfo colInfo) {
    ObjectInspector inspector = colInfo.getObjectInspector();
    if (inspector instanceof ConstantObjectInspector && inspector instanceof PrimitiveObjectInspector) {
        return toPrimitiveConstDesc(colInfo, inspector);
    }
    if (inspector instanceof ConstantObjectInspector && inspector instanceof ListObjectInspector) {
        ObjectInspector listElementOI = ((ListObjectInspector) inspector).getListElementObjectInspector();
        if (listElementOI instanceof PrimitiveObjectInspector) {
            return toListConstDesc(colInfo, inspector, listElementOI);
        }
    }
    if (inspector instanceof ConstantObjectInspector && inspector instanceof MapObjectInspector) {
        ObjectInspector keyOI = ((MapObjectInspector) inspector).getMapKeyObjectInspector();
        ObjectInspector valueOI = ((MapObjectInspector) inspector).getMapValueObjectInspector();
        if (keyOI instanceof PrimitiveObjectInspector && valueOI instanceof PrimitiveObjectInspector) {
            return toMapConstDesc(colInfo, inspector, keyOI, valueOI);
        }
    }
    if (inspector instanceof ConstantObjectInspector && inspector instanceof StructObjectInspector) {
        boolean allPrimitive = true;
        List<? extends StructField> fields = ((StructObjectInspector) inspector).getAllStructFieldRefs();
        for (StructField field : fields) {
            allPrimitive &= field.getFieldObjectInspector() instanceof PrimitiveObjectInspector;
        }
        if (allPrimitive) {
            return toStructConstDesc(colInfo, inspector, fields);
        }
    }
    // non-constant or non-primitive constants
    ExprNodeColumnDesc column = new ExprNodeColumnDesc(colInfo);
    column.setSkewedCol(colInfo.isSkewedCol());
    return column;
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) MapObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector) StructObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector) ListObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) ConstantObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector) StructField(org.apache.hadoop.hive.serde2.objectinspector.StructField) MapObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector) ListObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector) ExprNodeColumnDesc(org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) ConstantObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector) StructObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector)

Aggregations

ConstantObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector)36 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)25 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)19 UDFArgumentTypeException (org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException)14 UDFArgumentLengthException (org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException)12 ExprNodeConstantDesc (org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc)7 ArrayList (java.util.ArrayList)6 PrimitiveCategory (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory)6 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)5 UDFArgumentException (org.apache.hadoop.hive.ql.exec.UDFArgumentException)4 StructObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector)4 IntWritable (org.apache.hadoop.io.IntWritable)4 Text (org.apache.hadoop.io.Text)4 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)3 StringObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.StringObjectInspector)3 PrimitiveTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo)3 BytesWritable (org.apache.hadoop.io.BytesWritable)3 LongWritable (org.apache.hadoop.io.LongWritable)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 List (java.util.List)2