You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by mb...@apache.org on 2025/01/09 02:49:26 UTC
(calcite) 02/02: Casts between time intervals do not require scaling
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 <mb...@feldera.com>
AuthorDate: Wed Jan 8 17:16:46 2025 -0800
Casts between time intervals do not require scaling
Signed-off-by: Mihai Budiu <mb...@feldera.com>
---
.../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);