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]>
(cherry picked from commit b95c6ee)

# Conflicts:
#	fe/fe-core/src/test/java/com/starrocks/sql/plan/DecimalTypeTest.java
  • Loading branch information
Seaven authored and mergify[bot] committed Sep 4, 2024
1 parent 7ebcc77 commit 2dc0e1b
Show file tree
Hide file tree
Showing 2 changed files with 23 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,26 @@ public void testDecimalV2Cast() throws Exception {
plan = getFragmentPlan(sql);
assertContains(plan, "'12.56'");
}
<<<<<<< HEAD
=======

@Test
public void testDateToDecimal() throws Exception {
String sql = "select '1969-12-10 23:46:53' > c_0_0 from tab0";
String plan = getFragmentPlan(sql);
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");
}
>>>>>>> b95c6ee577 ([BugFix] Fix decimal literal equals uncheck type (#50626))
}

0 comments on commit 2dc0e1b

Please sign in to comment.