diff --git a/fe/fe-core/src/main/java/com/starrocks/analysis/DecimalLiteral.java b/fe/fe-core/src/main/java/com/starrocks/analysis/DecimalLiteral.java index aa070749906bf..534614ea58e12 100644 --- a/fe/fe-core/src/main/java/com/starrocks/analysis/DecimalLiteral.java +++ b/fe/fe-core/src/main/java/com/starrocks/analysis/DecimalLiteral.java @@ -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 diff --git a/fe/fe-core/src/test/java/com/starrocks/sql/plan/DecimalTypeTest.java b/fe/fe-core/src/test/java/com/starrocks/sql/plan/DecimalTypeTest.java index 1bddb8648e1f5..edf06c433a912 100644 --- a/fe/fe-core/src/test/java/com/starrocks/sql/plan/DecimalTypeTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/sql/plan/DecimalTypeTest.java @@ -275,4 +275,15 @@ public void testDateToDecimal() throws Exception { assertContains(plan, "1:Project\n" + " | : 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, " : 6: t1f * 1.0\n"); + } }