Skip to content

Commit

Permalink
Casts between time intervals do not require scaling
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
  • Loading branch information
mihaibudiu committed Jan 9, 2025
1 parent d6e4cc4 commit 129e5cc
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,10 @@ private static Expression scaleValue(
sourceType.getSqlTypeName().getEndUnit().multiplier;
return RexImpTable.multiplyDivide(operand, multiplier, divider);
}
if (SqlTypeName.INTERVAL_TYPES.contains(targetType.getSqlTypeName())) {
if (SqlTypeName.INTERVAL_TYPES.contains(targetType.getSqlTypeName())
&& !SqlTypeName.INTERVAL_TYPES.contains(sourceType.getSqlTypeName())) {
// Conversion between intervals is only allowed if the intervals have the same type,
// and then it should be a no-op.
final BigDecimal multiplier = targetType.getSqlTypeName().getEndUnit().multiplier;
final BigDecimal divider = BigDecimal.ONE;
return RexImpTable.multiplyDivide(operand, multiplier, divider);
Expand Down

0 comments on commit 129e5cc

Please sign in to comment.