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 901f9706fcd [fix](Nereids) datetimev2 literal equals should compare
microsecond (#40121)
901f9706fcd is described below
commit 901f9706fcd58d8436658739d32da2a312a6253d
Author: morrySnow <[email protected]>
AuthorDate: Fri Aug 30 13:56:05 2024 +0800
[fix](Nereids) datetimev2 literal equals should compare microsecond (#40121)
---
.../nereids/trees/expressions/literal/DateTimeV2Literal.java | 7 ++++++-
.../nereids/trees/expressions/literal/DateTimeLiteralTest.java | 10 ++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeV2Literal.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeV2Literal.java
index a3457f2463d..0ca19bf2a92 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeV2Literal.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeV2Literal.java
@@ -104,6 +104,11 @@ public class DateTimeV2Literal extends DateTimeLiteral {
getDataType().toCatalogDataType());
}
+ @Override
+ public double getDouble() {
+ return super.getDouble() + microSecond / 1000000.0;
+ }
+
@Override
public String toString() {
return getStringValue();
@@ -291,6 +296,6 @@ public class DateTimeV2Literal extends DateTimeLiteral {
return false;
}
DateTimeV2Literal literal = (DateTimeV2Literal) o;
- return Objects.equals(dataType, literal.dataType);
+ return Objects.equals(dataType, literal.dataType) &&
Objects.equals(microSecond, literal.microSecond);
}
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteralTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteralTest.java
index 2eeee30a38a..914246f08b6 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteralTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteralTest.java
@@ -490,4 +490,14 @@ class DateTimeLiteralTest {
Assertions.assertEquals(1, literal.roundCeiling(0).month);
Assertions.assertEquals(2001, literal.roundCeiling(0).year);
}
+
+ @Test
+ void testEquals() {
+ DateTimeV2Literal l1 = new DateTimeV2Literal(1, 1, 1, 1, 1, 1, 1);
+ DateTimeV2Literal l2 = new DateTimeV2Literal(1, 1, 1, 1, 1, 1, 1);
+ DateTimeV2Literal l3 = new DateTimeV2Literal(1, 1, 1, 1, 1, 1, 2);
+
+ Assertions.assertEquals(l1, l2);
+ Assertions.assertNotEquals(l1, l3);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]