@JsonIgnore public MajorType getMajorType() { MajorType.Builder b = MajorType.newBuilder(); b.setMode(mode); b.setMinorType(minorType); if (precision != null) { b.setPrecision(precision); } if (width != null) { b.setWidth(width); } if (scale != null) { b.setScale(scale); } return b.build(); }
setScale(other.getScale());
@JsonIgnore public MajorType getMajorType() { MajorType.Builder b = MajorType.newBuilder(); b.setMode(mode); b.setMinorType(minorType); if (precision != null) { b.setPrecision(precision); } if (width != null) { b.setWidth(width); } if (scale != null) { b.setScale(scale); } return b.build(); }
.setMode(DataMode.REQUIRED) .setPrecision(precision) .setScale(scale) .build(); } else {
switch(fieldType) { case Decimal: builder.setPrecision(((Decimal) arrowType).getPrecision()).setScale(((Decimal) arrowType).getScale()); break;
.unOrdered() .csvBaselineFile("testframework/decimal_test.tsv") .baselineTypes(MajorType.newBuilder().setMinorType(MinorType.DECIMAL).setMode(DataMode.REQUIRED).setPrecision(32).setScale(2).build())
break; case 5: builder.setScale(input.readInt32()); break; case 6:
.setMode(DataMode.OPTIONAL) .setPrecision(decimalField.getMajorType().getPrecision()) .setScale(decimalField.getMajorType().getScale());
/** * Helper method that converts Hive type definition to Dremio type definition. * * @param typeInfo Hive type info * @param options * @return */ public static MajorType getMajorTypeFromHiveTypeInfo(final TypeInfo typeInfo, final OptionManager options) { switch (typeInfo.getCategory()) { case PRIMITIVE: { PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo; MinorType minorType = getMinorTypeFromHivePrimitiveTypeInfo(primitiveTypeInfo, options); MajorType.Builder typeBuilder = MajorType.newBuilder().setMinorType(getMinorTypeFromArrowMinorType(minorType)) .setMode(DataMode.OPTIONAL); // Hive columns (both regular and partition) could have null values if (primitiveTypeInfo.getPrimitiveCategory() == PrimitiveCategory.DECIMAL) { DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) primitiveTypeInfo; typeBuilder.setPrecision(decimalTypeInfo.precision()) .setScale(decimalTypeInfo.scale()).build(); } return typeBuilder.build(); } case LIST: case MAP: case STRUCT: case UNION: default: throwUnsupportedHiveDataTypeError(typeInfo.getCategory().toString()); } return null; // never reached }
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 TypeProtos.MajorType toMajorType(PrimitiveType.PrimitiveTypeName primitiveTypeName, int length, TypeProtos.DataMode mode, SchemaElement schemaElement, OptionManager options, Field arrowField, final boolean readInt96AsTimeStamp) { MinorType minorType = getMinorType(primitiveTypeName, length, schemaElement, options, arrowField, readInt96AsTimeStamp); TypeProtos.MajorType.Builder typeBuilder = TypeProtos.MajorType.newBuilder().setMinorType(minorType).setMode(mode); if (CoreDecimalUtility.isDecimalType(minorType)) { typeBuilder.setPrecision(schemaElement.getPrecision()).setScale(schemaElement.getScale()); } return typeBuilder.build(); } }