/** * Default implementation. Maybe overridden by exact types. */ @Override public int scale() { return HiveDecimalUtils.getScaleForType(typeInfo); }
public static TypeInfo getDecimalTypeForPrimitiveCategories( PrimitiveTypeInfo a, PrimitiveTypeInfo b) { int prec1 = HiveDecimalUtils.getPrecisionForType(a); int prec2 = HiveDecimalUtils.getPrecisionForType(b); int scale1 = HiveDecimalUtils.getScaleForType(a); int scale2 = HiveDecimalUtils.getScaleForType(b); int intPart = Math.max(prec1 - scale1, prec2 - scale2); int decPart = Math.max(scale1, scale2); int prec = Math.min(intPart + decPart, HiveDecimal.MAX_PRECISION); int scale = Math.min(decPart, HiveDecimal.MAX_PRECISION - intPart); return TypeInfoFactory.getDecimalTypeInfo(prec, scale); }
public static DecimalTypeInfo getDecimalTypeForPrimitiveCategory(PrimitiveTypeInfo a) { if (a instanceof DecimalTypeInfo) return (DecimalTypeInfo)a; int prec = HiveDecimalUtils.getPrecisionForType(a); int scale = HiveDecimalUtils.getScaleForType(a); prec = Math.min(prec, HiveDecimal.MAX_PRECISION); scale = Math.min(scale, HiveDecimal.MAX_PRECISION - (prec - scale)); return TypeInfoFactory.getDecimalTypeInfo(prec, scale); } }
/** * Creates a DecimalTypeInfo object with appropriate precision and scale for the given * inputTypeInfo. */ private TypeInfo updatePrecision(TypeInfo inputTypeInfo, DecimalTypeInfo returnType) { if (!(inputTypeInfo instanceof PrimitiveTypeInfo)) { return returnType; } PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) inputTypeInfo; int precision = getPrecisionForType(ptinfo); // TODO: precision and scale would be practically invalid for string conversion (38,38) int scale = HiveDecimalUtils.getScaleForType(ptinfo); return new DecimalTypeInfo(precision, scale); }
/** * Creates a DecimalTypeInfo object with appropriate precision and scale for the given * inputTypeInfo. */ private TypeInfo updatePrecision(TypeInfo inputTypeInfo, DecimalTypeInfo returnType) { if (!(inputTypeInfo instanceof PrimitiveTypeInfo)) { return returnType; } PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) inputTypeInfo; int precision = getPrecisionForType(ptinfo); // TODO: precision and scale would be practically invalid for string conversion (38,38) int scale = HiveDecimalUtils.getScaleForType(ptinfo); return new DecimalTypeInfo(precision, scale); }
/** * Default implementation. Maybe overridden by exact types. */ @Override public int scale() { return HiveDecimalUtils.getScaleForType(typeInfo); }
/** * Default implementation. Maybe overridden by exact types. */ @Override public int scale() { return HiveDecimalUtils.getScaleForType(typeInfo); }
/** * Default implementation. Maybe overridden by exact types. */ @Override public int scale() { return HiveDecimalUtils.getScaleForType(typeInfo); }
/** * Default implementation. Maybe overridden by exact types. */ @Override public int scale() { return HiveDecimalUtils.getScaleForType(typeInfo); }
public static TypeInfo getDecimalTypeForPrimitiveCategories( PrimitiveTypeInfo a, PrimitiveTypeInfo b) { int prec1 = HiveDecimalUtils.getPrecisionForType(a); int prec2 = HiveDecimalUtils.getPrecisionForType(b); int scale1 = HiveDecimalUtils.getScaleForType(a); int scale2 = HiveDecimalUtils.getScaleForType(b); int intPart = Math.max(prec1 - scale1, prec2 - scale2); int decPart = Math.max(scale1, scale2); int prec = Math.min(intPart + decPart, HiveDecimal.MAX_PRECISION); int scale = Math.min(decPart, HiveDecimal.MAX_PRECISION - intPart); return TypeInfoFactory.getDecimalTypeInfo(prec, scale); }
public static TypeInfo getDecimalTypeForPrimitiveCategories( PrimitiveTypeInfo a, PrimitiveTypeInfo b) { int prec1 = HiveDecimalUtils.getPrecisionForType(a); int prec2 = HiveDecimalUtils.getPrecisionForType(b); int scale1 = HiveDecimalUtils.getScaleForType(a); int scale2 = HiveDecimalUtils.getScaleForType(b); int intPart = Math.max(prec1 - scale1, prec2 - scale2); int decPart = Math.max(scale1, scale2); int prec = Math.min(intPart + decPart, HiveDecimal.MAX_PRECISION); int scale = Math.min(decPart, HiveDecimal.MAX_PRECISION - intPart); return TypeInfoFactory.getDecimalTypeInfo(prec, scale); }
public static TypeInfo getDecimalTypeForPrimitiveCategories( PrimitiveTypeInfo a, PrimitiveTypeInfo b) { int prec1 = HiveDecimalUtils.getPrecisionForType(a); int prec2 = HiveDecimalUtils.getPrecisionForType(b); int scale1 = HiveDecimalUtils.getScaleForType(a); int scale2 = HiveDecimalUtils.getScaleForType(b); int intPart = Math.max(prec1 - scale1, prec2 - scale2); int decPart = Math.max(scale1, scale2); int prec = Math.min(intPart + decPart, HiveDecimal.MAX_PRECISION); int scale = Math.min(decPart, HiveDecimal.MAX_PRECISION - intPart); return TypeInfoFactory.getDecimalTypeInfo(prec, scale); }
public static TypeInfo getDecimalTypeForPrimitiveCategories( PrimitiveTypeInfo a, PrimitiveTypeInfo b) { int prec1 = HiveDecimalUtils.getPrecisionForType(a); int prec2 = HiveDecimalUtils.getPrecisionForType(b); int scale1 = HiveDecimalUtils.getScaleForType(a); int scale2 = HiveDecimalUtils.getScaleForType(b); int intPart = Math.max(prec1 - scale1, prec2 - scale2); int decPart = Math.max(scale1, scale2); int prec = Math.min(intPart + decPart, HiveDecimal.MAX_PRECISION); int scale = Math.min(decPart, HiveDecimal.MAX_PRECISION - intPart); return TypeInfoFactory.getDecimalTypeInfo(prec, scale); }
public static DecimalTypeInfo getDecimalTypeForPrimitiveCategory(PrimitiveTypeInfo a) { if (a instanceof DecimalTypeInfo) return (DecimalTypeInfo)a; int prec = HiveDecimalUtils.getPrecisionForType(a); int scale = HiveDecimalUtils.getScaleForType(a); prec = Math.min(prec, HiveDecimal.MAX_PRECISION); scale = Math.min(scale, HiveDecimal.MAX_PRECISION - (prec - scale)); return TypeInfoFactory.getDecimalTypeInfo(prec, scale); } }
public static DecimalTypeInfo getDecimalTypeForPrimitiveCategory(PrimitiveTypeInfo a) { if (a instanceof DecimalTypeInfo) return (DecimalTypeInfo)a; int prec = HiveDecimalUtils.getPrecisionForType(a); int scale = HiveDecimalUtils.getScaleForType(a); prec = Math.min(prec, HiveDecimal.MAX_PRECISION); scale = Math.min(scale, HiveDecimal.MAX_PRECISION - (prec - scale)); return TypeInfoFactory.getDecimalTypeInfo(prec, scale); } }
public static DecimalTypeInfo getDecimalTypeForPrimitiveCategory(PrimitiveTypeInfo a) { if (a instanceof DecimalTypeInfo) return (DecimalTypeInfo)a; int prec = HiveDecimalUtils.getPrecisionForType(a); int scale = HiveDecimalUtils.getScaleForType(a); prec = Math.min(prec, HiveDecimal.MAX_PRECISION); scale = Math.min(scale, HiveDecimal.MAX_PRECISION - (prec - scale)); return TypeInfoFactory.getDecimalTypeInfo(prec, scale); } }
public static DecimalTypeInfo getDecimalTypeForPrimitiveCategory(PrimitiveTypeInfo a) { if (a instanceof DecimalTypeInfo) return (DecimalTypeInfo)a; int prec = HiveDecimalUtils.getPrecisionForType(a); int scale = HiveDecimalUtils.getScaleForType(a); prec = Math.min(prec, HiveDecimal.MAX_PRECISION); scale = Math.min(scale, HiveDecimal.MAX_PRECISION - (prec - scale)); return TypeInfoFactory.getDecimalTypeInfo(prec, scale); } }
/** * Creates a DecimalTypeInfo object with appropriate precision and scale for the given * inputTypeInfo. */ private TypeInfo updatePrecision(TypeInfo inputTypeInfo, DecimalTypeInfo returnType) { if (!(inputTypeInfo instanceof PrimitiveTypeInfo)) { return returnType; } PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) inputTypeInfo; int precision = getPrecisionForType(ptinfo); int scale = HiveDecimalUtils.getScaleForType(ptinfo); return new DecimalTypeInfo(precision, scale); }