This is an automated email from the ASF dual-hosted git repository.
morrysnow 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 e1a116af94 [fix](planner)normalize the behavior of from_unixtime()
according to Nereids planner (#21723)
e1a116af94 is described below
commit e1a116af949797c80ff773c0161fcd48b891a767
Author: mch_ucchi <[email protected]>
AuthorDate: Tue Jul 18 12:15:38 2023 +0800
[fix](planner)normalize the behavior of from_unixtime() according to
Nereids planner (#21723)
if from_unixtime() receive an integer out of int range, the function
returns null.
---
.../src/main/java/org/apache/doris/rewrite/FEFunctions.java | 8 ++++----
.../src/test/java/org/apache/doris/rewrite/FEFunctionsTest.java | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
index 3a168e1850..a5cf6cb926 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
@@ -233,8 +233,8 @@ public class FEFunctions {
@FEFunction(name = "from_unixtime", argTypes = { "INT" }, returnType =
"VARCHAR")
public static StringLiteral fromUnixTime(LiteralExpr unixTime) throws
AnalysisException {
// if unixTime < 0, we should return null, throw a exception and let
BE process
- if (unixTime.getLongValue() < 0) {
- throw new AnalysisException("unixtime should larger than zero");
+ if (unixTime.getLongValue() < 0 || unixTime.getLongValue() >=
Integer.MAX_VALUE) {
+ throw new AnalysisException("unix timestamp out of range");
}
DateLiteral dl = new DateLiteral(unixTime.getLongValue() * 1000,
TimeUtils.getTimeZone(),
Type.DATETIME);
@@ -244,8 +244,8 @@ public class FEFunctions {
@FEFunction(name = "from_unixtime", argTypes = { "INT", "VARCHAR" },
returnType = "VARCHAR")
public static StringLiteral fromUnixTime(LiteralExpr unixTime,
StringLiteral fmtLiteral) throws AnalysisException {
// if unixTime < 0, we should return null, throw a exception and let
BE process
- if (unixTime.getLongValue() < 0) {
- throw new AnalysisException("unixtime should larger than zero");
+ if (unixTime.getLongValue() < 0 || unixTime.getLongValue() >=
Integer.MAX_VALUE) {
+ throw new AnalysisException("unix timestamp out of range");
}
DateLiteral dl = new DateLiteral(unixTime.getLongValue() * 1000,
TimeUtils.getTimeZone(),
Type.DATETIME);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/rewrite/FEFunctionsTest.java
b/fe/fe-core/src/test/java/org/apache/doris/rewrite/FEFunctionsTest.java
index 17d88215a1..9f444db9fa 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/rewrite/FEFunctionsTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/rewrite/FEFunctionsTest.java
@@ -250,7 +250,7 @@ public class FEFunctionsTest {
@Test
public void fromUnixTimeTestException() throws AnalysisException {
expectedEx.expect(AnalysisException.class);
- expectedEx.expectMessage("unixtime should larger than zero");
+ expectedEx.expectMessage("unix timestamp out of range");
FEFunctions.fromUnixTime(new IntLiteral(-100));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]