sb.append(mt.getPrecision()); sb.append(", "); sb.append(mt.getScale()); sb.append(")"); break;
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.getScale()));
case DECIMAL38SPARSE: Decimal fromDecimal = from.getType(Decimal.class); return to.getScale() == fromDecimal.getScale() && to.getPrecision() == fromDecimal.getPrecision(); case VARBINARY: case VARCHAR:
setScale(other.getScale());
int length = 0; for (int i = startPoint; i < startPoint + dataBuffer.readableBytes() - 1; i+=decimalLength) { final BigDecimal arrowDecimal = DecimalUtility.getBigDecimalFromArrowBuf(dataBuffer, i/16, decimalField.getMajorType().getScale()); final int startIndex = (i == startPoint) ? i : i + length; DecimalHelper.getSparseFromBigDecimal(arrowDecimal, drillBuffer, startIndex, decimalField.getMajorType().getScale(), NUMBER_DECIMAL_DIGITS); length += 8; .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; }
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; } }
/** * Get the <code>scale</code> of given type. * @param majorType * @return */ public static int getScale(MajorType majorType) { if (majorType.hasScale()) { return majorType.getScale(); } return 0; }
public static ArrowType getArrowTypeForMajorType(MajorType majorType) { if (majorType.getMinorType() == TypeProtos.MinorType.DECIMAL) { return new Decimal(majorType.getPrecision(), majorType.getScale()); } return getArrowMinorType(majorType.getMinorType()).getType(); }