This is an automated email from the ASF dual-hosted git repository.
zhangstar333 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new f7307875ae2 [function](signature) add datev2 signature for from_days
function (#36505)
f7307875ae2 is described below
commit f7307875ae213ce20c310d62cd773378e906f7c8
Author: zhangstar333 <[email protected]>
AuthorDate: Thu Jun 20 15:47:22 2024 +0800
[function](signature) add datev2 signature for from_days function (#36505)
## Proposed changes
add datev2 signature for from_days function
---
.../expressions/functions/executable/DateTimeExtractAndTransform.java | 4 ++--
.../doris/nereids/trees/expressions/functions/scalar/FromDays.java | 4 ++--
gensrc/script/doris_builtins_functions.py | 1 +
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
index b6960d4384b..754c13e43d1 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
@@ -389,7 +389,7 @@ public class DateTimeExtractAndTransform {
/**
* from_days.
*/
- @ExecFunction(name = "from_days", argTypes = {"INT"}, returnType = "DATE")
+ @ExecFunction(name = "from_days", argTypes = {"INT"}, returnType =
"DATEV2")
public static Expression fromDays(IntegerLiteral n) {
// doris treat 0000AD as ordinary year but java LocalDateTime treat it
as lunar year.
LocalDateTime res = LocalDateTime.of(0, 1, 1, 0, 0, 0)
@@ -397,7 +397,7 @@ public class DateTimeExtractAndTransform {
if (res.isBefore(LocalDateTime.of(0, 3, 1, 0, 0, 0))) {
res = res.plusDays(-1);
}
- return DateLiteral.fromJavaDateType(res);
+ return DateV2Literal.fromJavaDateType(res);
}
@ExecFunction(name = "last_day", argTypes = {"DATE"}, returnType = "DATE")
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromDays.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromDays.java
index 7adf680c0ef..a2b5a420c34 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromDays.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromDays.java
@@ -23,7 +23,7 @@ import
org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
import
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DateType;
+import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import com.google.common.base.Preconditions;
@@ -38,7 +38,7 @@ public class FromDays extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature,
AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
- FunctionSignature.ret(DateType.INSTANCE).args(IntegerType.INSTANCE)
+
FunctionSignature.ret(DateV2Type.INSTANCE).args(IntegerType.INSTANCE)
);
/**
diff --git a/gensrc/script/doris_builtins_functions.py
b/gensrc/script/doris_builtins_functions.py
index ee801bc7a1b..38c9f8ac886 100644
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -922,6 +922,7 @@ visible_functions = {
[['utc_timestamp'], 'DATETIME', [], 'ALWAYS_NOT_NULLABLE'],
[['timestamp'], 'DATETIME', ['DATETIME'], 'ALWAYS_NULLABLE'],
+ [['from_days'], 'DATEV2', ['INT'], 'ALWAYS_NULLABLE'],
[['from_days'], 'DATE', ['INT'], 'ALWAYS_NULLABLE'],
[['last_day'], 'DATE', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['last_day'], 'DATE', ['DATE'], 'ALWAYS_NULLABLE'],
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]