Skip to content

Commit

Permalink
[Bugfix] fix setDouble issue in jdbc with prepare stmt
Browse files Browse the repository at this point in the history
Signed-off-by: ShaoxunLi <[email protected]>
  • Loading branch information
ShaoxunLi committed Oct 14, 2024
1 parent 12cae59 commit db8bb99
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public FloatLiteral(String value) throws AnalysisException {
this(value, NodePosition.ZERO);
}

public FloatLiteral(String value, Type type) throws AnalysisException {
this(value, NodePosition.ZERO);
this.type = type;
}

public FloatLiteral(String value, NodePosition pos) throws AnalysisException {
super(pos);
Double floatValue = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static LiteralExpr create(String value, Type type) throws AnalysisExcepti
break;
case FLOAT:
case DOUBLE:
literalExpr = new FloatLiteral(value);
literalExpr = new FloatLiteral(value, type);
break;
case DECIMALV2:
case DECIMAL32:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.starrocks.catalog.PrimitiveType;
import com.starrocks.catalog.ScalarType;
import com.starrocks.catalog.Type;
import com.starrocks.common.AnalysisException;
import org.junit.Assert;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -181,6 +182,14 @@ public void floatAndDoubleExpr() throws AnalysisException {
Assert.assertTrue(0 == double1.compareLiteral(double2));
// self equal
Assert.assertTrue(0 == double1.compareLiteral(double1));

LiteralExpr floatType = LiteralExpr.create("3.14", Type.FLOAT);
Assert.assertEquals(PrimitiveType.FLOAT, floatType.getType().getPrimitiveType());
Assert.assertEquals(true, floatType.equals(new FloatLiteral(3.14, Type.FLOAT)));

LiteralExpr doubleType = LiteralExpr.create("3.14", Type.DOUBLE);
Assert.assertEquals(PrimitiveType.DOUBLE, doubleType.getType().getPrimitiveType());
Assert.assertEquals(true, doubleType.equals(new FloatLiteral(3.14, Type.DOUBLE)));
}

private void intTestInternal(ScalarType type) throws AnalysisException {
Expand Down

0 comments on commit db8bb99

Please sign in to comment.