org.apache.drill.common.types.TypeProtos.MajorType.Builder subBuilder = null; if (((bitField0_ & 0x00000001) == 0x00000001)) { subBuilder = majorType_.toBuilder();
public MaterializedField getOtherNullableVersion() { MajorType mt = type; DataMode newDataMode; switch (mt.getMode()){ case OPTIONAL: newDataMode = DataMode.REQUIRED; break; case REQUIRED: newDataMode = DataMode.OPTIONAL; break; default: throw new UnsupportedOperationException(); } return new MaterializedField(name, mt.toBuilder().setMode(newDataMode).build(), children); }
@Override public void setChildVector(ValueVector childVector) { // Unlike the repeated list vector, the (plain) list vector // adds the dummy vector as a child type. assert field.getChildren().size() == 1; assert field.getChildren().iterator().next().getType().getMinorType() == MinorType.LATE; field.removeChild(vector.getField()); super.setChildVector(childVector); // Initial LATE type vector not added as a subtype initially. // So, no need to remove it, just add the new subtype. Since the // MajorType is immutable, must build a new one and replace the type // in the materialized field. (We replace the type, rather than creating // a new materialized field, to preserve the link to this field from // a parent map, list or union.) assert field.getType().getSubTypeCount() == 0; field.replaceType( field.getType().toBuilder() .addSubType(childVector.getField().getType().getMinorType()) .build()); }
org.apache.drill.common.types.TypeProtos.MajorType.Builder subBuilder = null; if (((bitField0_ & 0x00000001) == 0x00000001)) { subBuilder = majorType_.toBuilder();
case "VARCHAR": case "CHAR": castType = Types.required(MinorType.VARCHAR).toBuilder().setPrecision(call.getType().getPrecision()).build(); break; case "INTEGER":
builder.remainder(child); builder.withIndex(); builder.finalType(vector.getField().getType().toBuilder().setMode(DataMode.OPTIONAL).build()); return builder.build(); } else {
returnValueType = getReturnType().toBuilder().setMode(DataMode.OPTIONAL).build(); out = g.declare(returnValueType); e = e.eq(JExpr.lit(0));
return new TypedNullConstant(e.getMajorType().toBuilder().setMode(DataMode.OPTIONAL).build()); } else {
Types.required(TypeProtos.MinorType.VARCHAR).toBuilder().setWidth( getOriginalScanRel().getCluster().getTypeFactory().createSqlType(SqlTypeName.VARCHAR).getPrecision()).build(); case "LONG": return Types.required(TypeProtos.MinorType.BIT); case "BINARY": return Types.required(TypeProtos.MinorType.VARBINARY).toBuilder().build(); case "ANY": case "DECIMAL":
/** * Calculates return type and its nullability. Precision and scale is not included. * * @param logicalExpressions logical expressions * @param attributes function attributes * @return return type */ @Override public TypeProtos.MajorType getType(List<LogicalExpression> logicalExpressions, FunctionAttributes attributes) { if (attributes.getReturnValue().getType().getMinorType() == TypeProtos.MinorType.UNION) { final Set<TypeProtos.MinorType> subTypes = Sets.newHashSet(); for (final ValueReference ref : attributes.getParameters()) { subTypes.add(ref.getType().getMinorType()); } final TypeProtos.MajorType.Builder builder = TypeProtos.MajorType.newBuilder() .setMinorType(TypeProtos.MinorType.UNION) .setMode(TypeProtos.DataMode.OPTIONAL); for (final TypeProtos.MinorType subType : subTypes) { builder.addSubType(subType); } return builder.build(); } return attributes.getReturnValue().getType().toBuilder() .setMode(FunctionUtils.getReturnTypeDataMode(logicalExpressions, attributes)) .build(); } }
/** * The vector mechanism here relies on the vector metadata. However, if the * main vector is nullable, it will contain a <code>values</code> vector which * is required. But the <code>values</code> vector will carry metadata that * declares it to be nullable. While this is clearly a bug, it is a bug that has * become a "feature" and cannot be changed. This code works around this feature * by parsing out the actual type of the vector. * * @param vector the vector to clone, the type of which may not match the * metadata declared within that vector * @return the actual major type of the vector */ protected static MajorType parseVectorType(ValueVector vector) { final MajorType purportedType = vector.getField().getType(); if (purportedType.getMode() != DataMode.OPTIONAL) { return purportedType; } // For nullable vectors, the purported type can be wrong. The "outer" // vector is nullable, but the internal "values" vector is required, though // it carries a nullable type -- that is, the metadata lies. if (vector instanceof NullableVector) { return purportedType; } return purportedType.toBuilder() .setMode(DataMode.REQUIRED) .build(); }
@Override public void setChildVector(ValueVector childVector) { // Unlike the repeated list vector, the (plain) list vector // adds the dummy vector as a child type. assert field.getChildren().size() == 1; assert field.getChildren().iterator().next().getType().getMinorType() == MinorType.LATE; field.removeChild(vector.getField()); super.setChildVector(childVector); // Initial LATE type vector not added as a subtype initially. // So, no need to remove it, just add the new subtype. Since the // MajorType is immutable, must build a new one and replace the type // in the materialized field. (We replace the type, rather than creating // a new materialized field, to preserve the link to this field from // a parent map, list or union.) assert field.getType().getSubTypeCount() == 0; field.replaceType( field.getType().toBuilder() .addSubType(childVector.getField().getType().getMinorType()) .build()); }
public MaterializedField getOtherNullableVersion() { MajorType mt = type; DataMode newDataMode; switch (mt.getMode()){ case OPTIONAL: newDataMode = DataMode.REQUIRED; break; case REQUIRED: newDataMode = DataMode.OPTIONAL; break; default: throw new UnsupportedOperationException(); } return new MaterializedField(name, mt.toBuilder().setMode(newDataMode).build(), children); }
MajorType getLastPathType() { if ((this.getField().getType().getMinorType() == MinorType.LIST && this.getField().getType().getMode() == DataMode.REPEATED)) { // Use Repeated scalar type instead of Required List. VectorWithOrdinal vord = getChildVectorWithOrdinal(null); ValueVector v = vord.vector; if (!(v instanceof AbstractContainerVector)) { return v.getField().getType(); } } else if (this.getField().getType().getMinorType() == MinorType.MAP && this.getField().getType().getMode() == DataMode.REPEATED) { // Use Required Map return this.getField().getType().toBuilder().setMode(DataMode.REQUIRED).build(); } return this.getField().getType(); }
public MaterializedField cloneEmpty() { return create(name, type.toBuilder() .clearSubType() .build()); }
Types.required(TypeProtos.MinorType.VARCHAR).toBuilder().setWidth( getOriginalScanRel().getCluster().getTypeFactory().createSqlType(SqlTypeName.VARCHAR).getPrecision()).build(); case "LONG": return Types.required(TypeProtos.MinorType.BIT); case "BINARY": return Types.required(TypeProtos.MinorType.VARBINARY).toBuilder().build(); case "ANY": case "DECIMAL":
MajorType getLastPathType() { if ((this.getField().getType().getMinorType() == MinorType.LIST && this.getField().getType().getMode() == DataMode.REPEATED)) { // Use Repeated scalar type instead of Required List. VectorWithOrdinal vord = getChildVectorWithOrdinal(null); ValueVector v = vord.vector; if (!(v instanceof AbstractContainerVector)) { return v.getField().getType(); } } else if (this.getField().getType().getMinorType() == MinorType.MAP && this.getField().getType().getMode() == DataMode.REPEATED) { // Use Required Map return this.getField().getType().toBuilder().setMode(DataMode.REQUIRED).build(); } return this.getField().getType(); }
public MaterializedField cloneEmpty() { return create(name, type.toBuilder() .clearSubType() .build()); }