sb.append(mt.getPrecision()); sb.append(", "); sb.append(mt.getScale());
return new Field(name, true, new Decimal(serializedField.getMajorType().getPrecision(), serializedField.getMajorType().getScale()), null); default: return new Field(name, true, arrowMinorType.getType(), null);
newArgs.add(new ValueExpressions.LongExpression(targetType.getPrecision())); newArgs.add(new ValueExpressions.LongExpression(targetType.getScale()));
case DECIMAL38SPARSE: Decimal fromDecimal = from.getType(Decimal.class); return to.getScale() == fromDecimal.getScale() && to.getPrecision() == fromDecimal.getPrecision(); case VARBINARY: case VARCHAR:
setPrecision(other.getPrecision());
.setMinorType(MinorType.DECIMAL38SPARSE) .setMode(DataMode.OPTIONAL) .setPrecision(decimalField.getMajorType().getPrecision()) .setScale(decimalField.getMajorType().getScale());
public void writeTo(io.protostuff.Output output, com.dremio.common.types.TypeProtos.MajorType message) throws java.io.IOException { if(message.hasMinorType()) output.writeEnum(1, message.getMinorType().getNumber(), false); if(message.hasMode()) output.writeEnum(2, message.getMode().getNumber(), false); if(message.hasWidth()) output.writeInt32(3, message.getWidth(), false); if(message.hasPrecision()) output.writeInt32(4, message.getPrecision(), false); if(message.hasScale()) output.writeInt32(5, message.getScale(), false); if(message.hasTimeZone()) output.writeInt32(6, message.getTimeZone(), false); for(com.dremio.common.types.TypeProtos.MinorType subType : message.getSubTypeList()) output.writeEnum(7, subType.getNumber(), true); } public boolean isInitialized(com.dremio.common.types.TypeProtos.MajorType message)
public static MajorTypeHolder get(MajorType mt) { MajorTypeHolder h = new MajorTypeHolder(); h.minorType = mt.getMinorType(); h.mode = mt.getMode(); if (mt.hasPrecision()) { h.precision = mt.getPrecision(); } if (mt.hasScale()) { h.scale = mt.getScale(); } if (mt.hasWidth()) { h.width = mt.getWidth(); } return h; } }
private String getDecimalPrecisionScaleInfo(MajorType type) { String precision = ""; switch(type.getMinorType()) { case DECIMAL18: case DECIMAL28SPARSE: case DECIMAL38SPARSE: case DECIMAL38DENSE: case DECIMAL28DENSE: case DECIMAL9: precision = String.format("(%d,%d)", type.getPrecision(), type.getScale()); break; default: ; // do nothing empty string set above } return precision; }
/** * Get the <code>precision</code> of given type. * @param majorType * @return */ public static int getPrecision(MajorType majorType) { MinorType type = majorType.getMinorType(); if (majorType.hasPrecision()) { return majorType.getPrecision(); } if (type == MinorType.VARBINARY || type == MinorType.VARCHAR) { return 65536; } return 0; }
public static MajorType overrideMode(final MajorType originalMajorType, final DataMode overrideMode) { return withScaleAndPrecision(originalMajorType.getMinorType(), overrideMode, originalMajorType.getScale(), originalMajorType.getPrecision()); }
public static DecimalMetadata getDecimalMetadataForField(MajorType type) { switch(type.getMinorType()) { case DECIMAL: case DECIMAL9: case DECIMAL18: case DECIMAL28SPARSE: case DECIMAL28DENSE: case DECIMAL38SPARSE: case DECIMAL38DENSE: return new DecimalMetadata(type.getPrecision(), type.getScale()); default: return null; } }
public static ArrowType getArrowTypeForMajorType(MajorType majorType) { if (majorType.getMinorType() == TypeProtos.MinorType.DECIMAL) { return new Decimal(majorType.getPrecision(), majorType.getScale()); } return getArrowMinorType(majorType.getMinorType()).getType(); }