Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] fix setDouble issue in jdbc with prepare stmt #51811

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading