@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(); }
setState(198); ((CharTypeContext)_localctx).typeLen = typeLen(); ((CharTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.VARCHAR).setMode(DataMode.REQUIRED).setPrecision(((CharTypeContext)_localctx).typeLen.length.intValue()).build(); setState(202); ((CharTypeContext)_localctx).typeLen = typeLen(); ((CharTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.VARBINARY).setMode(DataMode.REQUIRED).setPrecision(((CharTypeContext)_localctx).typeLen.length.intValue()).build();
@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL18).setScale(scale).setPrecision(precision).setMode(DataMode.REQUIRED).build(); }
public static TypeProtos.MajorType toMajorType(PrimitiveType.PrimitiveTypeName primitiveTypeName, int length, TypeProtos.DataMode mode, SchemaElement schemaElement, OptionManager options) { ConvertedType convertedType = schemaElement.getConverted_type(); MinorType minorType = getMinorType(primitiveTypeName, length, convertedType, options); TypeProtos.MajorType.Builder typeBuilder = TypeProtos.MajorType.newBuilder().setMinorType(minorType).setMode(mode); if (Types.isDecimalType(minorType)) { int precision = schemaElement.getPrecision(); int scale = schemaElement.getScale(); typeBuilder.setPrecision(precision).setScale(scale); } return typeBuilder.build(); }
@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.VARDECIMAL) .setScale(scale) .setPrecision(precision) .setMode(DataMode.REQUIRED) .build(); }
@Override public MajorType majorType() { return MajorType.newBuilder() .setMinorType(type) .setMode(mode) .setPrecision(precision) .setScale(scale) .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(); }
setState(144); match(CParen); ((NumTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.DECIMAL9).setMode(DataMode.REQUIRED).setPrecision(((NumTypeContext)_localctx).precision.value.intValue()).setScale(((NumTypeContext)_localctx).scale.value.intValue()).build(); setState(152); match(CParen); ((NumTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.DECIMAL18).setMode(DataMode.REQUIRED).setPrecision(((NumTypeContext)_localctx).precision.value.intValue()).setScale(((NumTypeContext)_localctx).scale.value.intValue()).build(); setState(160); match(CParen); ((NumTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.DECIMAL28DENSE).setMode(DataMode.REQUIRED).setPrecision(((NumTypeContext)_localctx).precision.value.intValue()).setScale(((NumTypeContext)_localctx).scale.value.intValue()).build(); setState(168); match(CParen); ((NumTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.DECIMAL28SPARSE).setMode(DataMode.REQUIRED).setPrecision(((NumTypeContext)_localctx).precision.value.intValue()).setScale(((NumTypeContext)_localctx).scale.value.intValue()).build(); setState(176); match(CParen); ((NumTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.DECIMAL38DENSE).setMode(DataMode.REQUIRED).setPrecision(((NumTypeContext)_localctx).precision.value.intValue()).setScale(((NumTypeContext)_localctx).scale.value.intValue()).build(); setState(184); match(CParen); ((NumTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.DECIMAL38SPARSE).setMode(DataMode.REQUIRED).setPrecision(((NumTypeContext)_localctx).precision.value.intValue()).setScale(((NumTypeContext)_localctx).scale.value.intValue()).build(); setState(192); match(CParen); ((NumTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.VARDECIMAL).setMode(DataMode.REQUIRED).setPrecision(((NumTypeContext)_localctx).precision.value.intValue()).setScale(((NumTypeContext)_localctx).scale.value.intValue()).build();
.setMinorType(minorType) .setScale(scale) .setPrecision(width) .build(); final MaterializedField field = MaterializedField.create(name, type);
break; case 4: builder.setPrecision(input.readInt32()); break; case 5:
case VARCHAR: BaseCharTypeInfo baseCharTypeInfo = (BaseCharTypeInfo) primitiveTypeInfo; typeBuilder.setPrecision(baseCharTypeInfo.getLength()); break; case DECIMAL: DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) primitiveTypeInfo; typeBuilder.setPrecision(decimalTypeInfo.getPrecision()).setScale(decimalTypeInfo.getScale()); break; default:
setPrecision(other.getPrecision());
/** * 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; }
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(); }
@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL9).setScale(scale).setPrecision(precision).setMode(DataMode.REQUIRED).build(); }
@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL18).setScale(scale).setPrecision(precision).setMode(DataMode.REQUIRED).build(); }
@Override public MajorType getMajorType() { return MajorType .newBuilder() .setMinorType(MinorType.VARDECIMAL) .setScale(scale) .setPrecision(precision) .setMode(DataMode.REQUIRED) .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(); }