Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](Nereids) datetimev2 literal equals should compare microsecond #40121

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public LiteralExpr toLegacyLiteral() {
getDataType().toCatalogDataType());
}

@Override
public double getDouble() {
return super.getDouble() + microSecond / 1000000.0;
}

@Override
public String toString() {
return getStringValue();
Expand Down Expand Up @@ -291,6 +296,6 @@ public boolean equals(Object o) {
return false;
}
DateTimeV2Literal literal = (DateTimeV2Literal) o;
return Objects.equals(dataType, literal.dataType);
return Objects.equals(dataType, literal.dataType) && Objects.equals(microSecond, literal.microSecond);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,14 @@ void testRoundCeiling() {
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);
}
}
Loading