oih.staticInvoke("getDrillObjectInspector") .arg(mode.staticInvoke("valueOf").arg(JExpr.lit(argTypes[i].getMode().getNumber()))) .arg(mt.staticInvoke("valueOf").arg(JExpr.lit(argTypes[i].getMinorType().getNumber()))) .arg((((PrimitiveObjectInspector) returnOI).getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.STRING) ? JExpr.lit(true) : JExpr.lit(false)));
e.getInput().accept(this, sb); sb.append(" ) as "); sb.append(mt.getMinorType().name());
org.apache.drill.common.types.TypeProtos.MinorType value = org.apache.drill.common.types.TypeProtos.MinorType.valueOf(rawValue); if (value == null) { unknownFields.mergeVarintField(1, rawValue); org.apache.drill.common.types.TypeProtos.MinorType value = org.apache.drill.common.types.TypeProtos.MinorType.valueOf(rawValue); if (value == null) { unknownFields.mergeVarintField(7, rawValue); while(input.getBytesUntilLimit() > 0) { int rawValue = input.readEnum(); org.apache.drill.common.types.TypeProtos.MinorType value = org.apache.drill.common.types.TypeProtos.MinorType.valueOf(rawValue); if (value == null) { unknownFields.mergeVarintField(7, rawValue);
org.apache.drill.common.types.TypeProtos.MinorType value = org.apache.drill.common.types.TypeProtos.MinorType.valueOf(rawValue); if (value == null) { unknownFields.mergeVarintField(1, rawValue); org.apache.drill.common.types.TypeProtos.MinorType value = org.apache.drill.common.types.TypeProtos.MinorType.valueOf(rawValue); if (value == null) { unknownFields.mergeVarintField(7, rawValue); while(input.getBytesUntilLimit() > 0) { int rawValue = input.readEnum(); org.apache.drill.common.types.TypeProtos.MinorType value = org.apache.drill.common.types.TypeProtos.MinorType.valueOf(rawValue); if (value == null) { unknownFields.mergeVarintField(7, rawValue);
if (currentArg.equals(NullExpression.INSTANCE) && !MinorType.LATE.equals(parmType.getMinorType()) && (TypeProtos.DataMode.OPTIONAL.equals(parmType.getMode()) || matchedFuncHolder.getNullHandling() == FunctionTemplate.NullHandling.NULL_IF_NULL)) {
return arg; // Type will be same as argument. default: castType = Types.required(MinorType.valueOf(call.getType().getSqlTypeName().getName()));
return getList().getAccessor().getObject(index); default: throw new UnsupportedOperationException("Cannot support type: " + MinorType.valueOf(type));
org.apache.drill.common.types.TypeProtos.MinorType value = org.apache.drill.common.types.TypeProtos.MinorType.valueOf(rawValue); if (value == null) { unknownFields.mergeVarintField(1, rawValue); org.apache.drill.common.types.TypeProtos.MinorType value = org.apache.drill.common.types.TypeProtos.MinorType.valueOf(rawValue); if (value == null) { unknownFields.mergeVarintField(2, rawValue);
private boolean castEqual(ExpressionPosition pos, MajorType from, MajorType to) { if (!from.getMinorType().equals(to.getMinorType())) { return false;
TypeProtos.MinorType destType = holderExpr.getMajorType().getMinorType(); if (srcType.equals(destType)) {
case "DECIMAL": return null; default: return Types.required(TypeProtos.MinorType.valueOf(typeStr));
final CastExpression indexedCast = (CastExpression) indexed; if (expr.getInput().equals(indexedCast.getInput()) && expr.getMajorType().getMinorType().equals(indexedCast.getMajorType().getMinorType())
@SuppressWarnings("resource") private static ValueVector coerceVector(ValueVector v, VectorContainer c, MaterializedField field, int recordCount, BufferAllocator allocator) { if (v != null) { int valueCount = v.getAccessor().getValueCount(); TransferPair tp = v.getTransferPair(allocator); tp.transfer(); if (v.getField().getType().getMinorType().equals(field.getType().getMinorType())) { if (field.getType().getMinorType() == MinorType.UNION) { UnionVector u = (UnionVector) tp.getTo(); for (MinorType t : field.getType().getSubTypeList()) { u.addSubType(t); } } return tp.getTo(); } else { ValueVector newVector = TypeHelper.getNewVector(field, allocator); Preconditions.checkState(field.getType().getMinorType() == MinorType.UNION, "Can only convert vector to Union vector"); UnionVector u = (UnionVector) newVector; u.setFirstType(tp.getTo(), valueCount); return u; } } else { v = TypeHelper.getNewVector(field, allocator); v.allocateNew(); v.getMutator().setValueCount(recordCount); return v; } }
private AbstractObjectWriter buildUnion(UnionVector vector, VectorDescrip descrip) { // Dummy writers are used when the schema is known up front, but the // query chooses not to project a column. Variants are used in the case when // the schema is not known, and we discover it on the fly. In this case, // (which currently occurs only in JSON) dummy vectors are not used. if (vector == null) { throw new UnsupportedOperationException("Dummy variant writer not yet supported"); } final AbstractObjectWriter variants[] = new AbstractObjectWriter[MinorType.values().length]; final MetadataProvider mdProvider = descrip.childProvider(); int i = 0; for (final MinorType type : vector.getField().getType().getSubTypeList()) { // This call will create the vector if it does not yet exist. // Will throw an exception for unsupported types. // so call this only if the MajorType reports that the type // already exists. final ValueVector memberVector = vector.getMember(type); final VectorDescrip memberDescrip = new VectorDescrip(mdProvider, i++, memberVector.getField()); variants[type.ordinal()] = buildVectorWriter(memberVector, memberDescrip); } return new VariantObjectWriter( new UnionWriterImpl(descrip.metadata, vector, variants)); }
/** * Rebind the null state reader to include the union's own state. */ private void rebindMemberNullState() { for (int i = 0; i < variants.length; i++) { AbstractObjectReader objReader = variants[i]; if (objReader == null) { continue; } NullStateReader nullReader; MinorType type = MinorType.values()[i]; switch(type) { case MAP: case LIST: nullReader = new NullStateReaders.ComplexMemberStateReader(typeReader, type); break; default: nullReader = new NullStateReaders.MemberNullStateReader(nullStateReader, objReader.events().nullStateReader()); } objReader.events().bindNullState(nullReader); } }
/** * We treat fields with same set of Subtypes as equal, even if they are in a different order * @param t1 * @param t2 * @return */ private boolean majorTypeEqual(MajorType t1, MajorType t2) { if (t1.equals(t2)) { return true; } if (!t1.getMinorType().equals(t2.getMinorType())) { return false; } if (!t1.getMode().equals(t2.getMode())) { return false; } if (!Sets.newHashSet(t1.getSubTypeList()).equals(Sets.newHashSet(t2.getSubTypeList()))) { return false; } return true; }
/** * Sets max precision from both types if these types are string scalar types. * Sets max precision and scale from both types if these types are decimal types. * Both types should be of the same minor type. * * @param leftType type from left side * @param rightType type from right side * @param typeBuilder type builder * @return type builder */ public static MajorType.Builder calculateTypePrecisionAndScale(MajorType leftType, MajorType rightType, MajorType.Builder typeBuilder) { if (leftType.getMinorType().equals(rightType.getMinorType())) { boolean isScalarString = Types.isScalarStringType(leftType) && Types.isScalarStringType(rightType); boolean isDecimal = isDecimalType(leftType); if ((isScalarString || isDecimal) && leftType.hasPrecision() && rightType.hasPrecision()) { typeBuilder.setPrecision(Math.max(leftType.getPrecision(), rightType.getPrecision())); } if (isDecimal && leftType.hasScale() && rightType.hasScale()) { typeBuilder.setScale(Math.max(leftType.getScale(), rightType.getScale())); } } return typeBuilder; }