Skip to content

Commit

Permalink
[BugFix] Fix decimal literal equals uncheck type (#50626)
Browse files Browse the repository at this point in the history
Signed-off-by: Seaven <[email protected]>
  • Loading branch information
Seaven authored Sep 4, 2024
1 parent e09b33a commit b95c6ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public int hashCode() {

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,15 @@ public void testDateToDecimal() throws Exception {
assertContains(plan, "1:Project\n" +
" | <slot 16> : CAST(1: c_0_0 AS DOUBLE) < CAST('1969-12-10 23:46:53' AS DOUBLE)");
}

@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");
}
}

0 comments on commit b95c6ee

Please sign in to comment.