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

[BugFix] Fix decimal literal equals uncheck type (backport #50626) #50661

Merged
merged 1 commit into from
Sep 6, 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 @@ -492,4 +492,10 @@ public Expr uncheckedCastTo(Type targetType) throws AnalysisException {
public int hashCode() {
return Objects.hash(super.hashCode(), value);
}

@Override
public boolean equals(Object obj) {
return super.equals(obj) && (type.matchesType(((LiteralExpr) obj).getType()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,15 @@ public void testExpressionRangeCheck() throws Exception {
String plan = getFragmentPlan(sql);
assertContains(plan, "PREDICATES: 4: c_1_3 <= 1000");
}

@Test
public void testSameValueDiffTypeDecimal() throws Exception {
String sql = "SELECT t1a,\n" +
" sum(t1f * 1.00000000000) / NULLIF(sum(t1c), 0) AS aaaa,\n" +
" sum(t1f * 1.000) / NULLIF(sum(t1d * 1.000), 0) * 1000 AS bbbb\n" +
" FROM test_all_type \n" +
" GROUP BY t1a;\n ";
String plan = getFragmentPlan(sql);
assertContains(plan, "<slot 11> : 6: t1f * 1.0\n");
}
}
Loading