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
…50661)

Co-authored-by: Seaven <[email protected]>
  • Loading branch information
mergify[bot] and Seaven authored Sep 6, 2024
1 parent 0a43806 commit 7209a49
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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");
}
}

0 comments on commit 7209a49

Please sign in to comment.