Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,15 @@ private static Optional<DataType> getCommonDataTypeWithFloatNumericType(DataType
|| rightType instanceof SmallIntType) {
return Optional.of(leftType);
}
// For BigIntType and LargeIntType, using DoubleType would lose precision
// because double only has 53 bits of mantissa (about 15-17 significant digits).
// BigInt can represent up to 19 digits, and LargeInt up to 39 digits.
// Use DecimalV3Type to preserve exact integer representation.
if (rightType instanceof BigIntType || rightType instanceof LargeIntType) {
return Optional.of(DecimalV3Type.widerDecimalV3Type(
DecimalV3Type.forType(leftType),
DecimalV3Type.forType(rightType), true));
}
return Optional.of(DoubleType.INSTANCE);
}

Expand Down Expand Up @@ -1758,6 +1767,16 @@ private static Optional<DataType> findCommonPrimitiveTypeForComparison(
// numeric
if (leftType.isFloatType() || leftType.isDoubleType()
|| rightType.isFloatType() || rightType.isDoubleType()) {
// For BigIntType and LargeIntType, using DoubleType loses precision
// because double only has 53 bits of mantissa (~15-17 significant digits).
// BigInt can represent up to 19 digits, and LargeInt up to 39 digits.
// Use DecimalV3Type to preserve exact integer representation.
if (leftType instanceof BigIntType || leftType instanceof LargeIntType
|| rightType instanceof BigIntType || rightType instanceof LargeIntType) {
return Optional.of(DecimalV3Type.widerDecimalV3Type(
DecimalV3Type.forType(leftType),
DecimalV3Type.forType(rightType), true));
}
return Optional.of(DoubleType.INSTANCE);
}
if (leftType.isNumericType() && rightType.isNumericType()) {
Expand Down
Loading