This is an automated email from the ASF dual-hosted git repository.

mbudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 129e5cc89cafa0d55e3d4c1925ca7cafee888bdd
Author: Mihai Budiu <[email protected]>
AuthorDate: Wed Jan 8 17:16:46 2025 -0800

    Casts between time intervals do not require scaling
    
    Signed-off-by: Mihai Budiu <[email protected]>
---
 .../org/apache/calcite/adapter/enumerable/RexToLixTranslator.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
index b3e8c24446..2569d3c065 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
@@ -1223,7 +1223,10 @@ public class RexToLixTranslator implements 
RexVisitor<RexToLixTranslator.Result>
           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);

Reply via email to