@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL28SPARSE).setScale(bigDecimal.scale()).setPrecision(bigDecimal.precision()).setMode(DataMode.REQUIRED).build(); }
@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL38SPARSE).setScale(bigDecimal.scale()).setPrecision(bigDecimal.precision()).setMode(DataMode.REQUIRED).build(); }
/** * <code>optional .common.MajorType major_type = 1;</code> * * <pre> * the type associated with this field. * </pre> */ public Builder setMajorType( org.apache.drill.common.types.TypeProtos.MajorType.Builder builderForValue) { if (majorTypeBuilder_ == null) { majorType_ = builderForValue.build(); onChanged(); } else { majorTypeBuilder_.setMessage(builderForValue.build()); } bitField0_ |= 0x00000001; return this; } /**
@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()); }
@Test public void testXpath_Double() throws Exception { final String query = "select xpath_double ('<a><b>20</b><c>40</c></a>', 'a/b * a/c') as col \n" + "from hive.kv \n" + "limit 0"; final TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder() .setMinorType(TypeProtos.MinorType.FLOAT8) .setMode(TypeProtos.DataMode.OPTIONAL) .build(); final List<Pair<SchemaPath, TypeProtos.MajorType>> expectedSchema = Lists.newArrayList(); expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col"), majorType)); testBuilder() .sqlQuery(query) .schemaBaseLine(expectedSchema) .build() .run(); }
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); }
public static MajorType withScaleAndPrecision(final MinorType type, final DataMode mode, final int scale, final int precision) { return MajorType.newBuilder().setMinorType(type).setMode(mode).setScale(scale).setPrecision(precision).build(); }
public static MajorType withMode(final MinorType type, final DataMode mode) { return MajorType.newBuilder().setMode(mode).setMinorType(type).build(); }
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 static MajorType optional(final MinorType type) { return MajorType.newBuilder().setMode(DataMode.OPTIONAL).setMinorType(type).build(); }
public static MajorType repeated(final MinorType type) { return MajorType.newBuilder().setMode(REPEATED).setMinorType(type).build(); }
@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL9).setScale(scale).setPrecision(precision).setMode(DataMode.REQUIRED).build(); }
public static MajorType required(final MinorType type) { return MajorType.newBuilder().setMode(DataMode.REQUIRED).setMinorType(type).build(); }
@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL18).setScale(scale).setPrecision(precision).setMode(DataMode.REQUIRED).build(); }
public TypedNullConstant(MajorType type) { super(null); this.type = TypeProtos.MajorType.newBuilder().mergeFrom(type).setMode(DataMode.OPTIONAL).build(); }
public void addSubType(MinorType type) { if (field.getType().getSubTypeList().contains(type)) { return; } field.replaceType( MajorType.newBuilder(field.getType()).addSubType(type).build()); if (callBack != null) { callBack.doWork(); } }
@Override public TypeProtos.MajorType getVectorType(SchemaPath column, PlannerSettings plannerSettings) { HiveScan hiveScan = (HiveScan) scanRel.getGroupScan(); String partitionName = column.getAsNamePart().getName(); Map<String, String> partitionNameTypeMap = hiveScan.getHiveReadEntry().table.getPartitionNameTypeMap(); String hiveType = partitionNameTypeMap.get(partitionName); PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromTypeString(hiveType); TypeProtos.MinorType partitionType = HiveUtilities.getMinorTypeFromHivePrimitiveTypeInfo(primitiveTypeInfo, plannerSettings.getOptions()); return TypeProtos.MajorType.newBuilder().setMode(TypeProtos.DataMode.OPTIONAL).setMinorType(partitionType).build(); }
/** * Builds major type using given minor type, data mode and precision. * * @param type minor type * @param mode data mode * @param precision precision value * @return major type */ public static MajorType withPrecision(final MinorType type, final DataMode mode, final int precision) { return MajorType.newBuilder().setMinorType(type).setMode(mode).setPrecision(precision).build(); }
@Override public MajorType getMajorType() { return MajorType .newBuilder() .setMinorType(MinorType.VARDECIMAL) .setScale(scale) .setPrecision(precision) .setMode(DataMode.REQUIRED) .build(); }
public MaterializedField cloneEmpty() { return create(name, type.toBuilder() .clearSubType() .build()); }