You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2024/04/12 08:24:12 UTC
(kylin) 09/35: KYLIN-5791 & KYLIN-5801 Fix computation of timestampdff & add_month
This is an automated email from the ASF dual-hosted git repository.
liyang pushed a commit to branch kylin5
in repository https://gitbox.apache.org/repos/asf/kylin.git
commit e33ef57cce3f3865ca9b4a6f132a170257d46be2
Author: liang.huang <83...@users.noreply.github.com>
AuthorDate: Thu Aug 31 10:46:48 2023 +0800
KYLIN-5791 & KYLIN-5801 Fix computation of timestampdff & add_month
1. Add datetype for add_month function as required
2. Support string args for Timestampdiff constant computation
---
pom.xml | 2 +-
.../scala/org/apache/kylin/query/runtime/SparderRexVisitor.scala | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index ccbdfbae22..940eb93ff0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -135,7 +135,7 @@
<scala-retry>0.3.0</scala-retry>
<!-- Calcite Version -->
- <calcite.version>1.116.0-kylin-4.x-r035</calcite.version>
+ <calcite.version>1.116.0-kylin-4.x-r036</calcite.version>
<avatica.version>4.x_1.10-r01</avatica.version>
<!-- Hadoop Common deps, keep compatible with hadoop2.version -->
diff --git a/src/spark-project/sparder/src/main/scala/org/apache/kylin/query/runtime/SparderRexVisitor.scala b/src/spark-project/sparder/src/main/scala/org/apache/kylin/query/runtime/SparderRexVisitor.scala
index 0b7116a673..b8e34366b8 100644
--- a/src/spark-project/sparder/src/main/scala/org/apache/kylin/query/runtime/SparderRexVisitor.scala
+++ b/src/spark-project/sparder/src/main/scala/org/apache/kylin/query/runtime/SparderRexVisitor.scala
@@ -171,7 +171,12 @@ class SparderRexVisitor(val inputFieldNames: Seq[String],
case num: MonthNum => {
// both add_month and add_year case
val ts = k_lit(children.head).cast(TimestampType)
- return k_lit(k_add_months(k_lit(ts), num.num))
+ call.getType.getSqlTypeName match {
+ case SqlTypeName.DATE =>
+ return k_lit(k_add_months(k_lit(ts), num.num)).cast(DateType)
+ case _ =>
+ return k_lit(k_add_months(k_lit(ts), num.num))
+ }
}
case _ =>
}