Skip to content

Commit

Permalink
[BugFix] Fix decimal literal equals uncheck type (backport #50626) (#…
Browse files Browse the repository at this point in the history
…50658)

Co-authored-by: Seaven <[email protected]>
  • Loading branch information
mergify[bot] and Seaven authored Sep 6, 2024
1 parent d30791c commit d15718d
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 @@ -519,6 +519,6 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return super.equals(obj);
return super.equals(obj) && (type.matchesType(((LiteralExpr) obj).getType()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,15 @@ public void testDecimalV2Cast() throws Exception {
plan = getFragmentPlan(sql);
assertContains(plan, "'12.56'");
}

@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 d15718d

Please sign in to comment.