Skip to content
Closed
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 @@ -581,8 +581,7 @@ public Optional<ResultSet> handleQueryInFe(StatementBase parsedStmt) {
return Optional.of(resultSet);
} else if (child instanceof PhysicalEmptyRelation) {
List<Column> columns = Lists.newArrayList();
PhysicalEmptyRelation physicalEmptyRelation = (PhysicalEmptyRelation) physicalPlan.child(0);
for (int i = 0; i < physicalEmptyRelation.getProjects().size(); i++) {
for (int i = 0; i < physicalPlan.getOutput().size(); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the relation between this for loop with round function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is another bug, and have no relation with round function

NamedExpression output = physicalPlan.getOutput().get(i);
columns.add(new Column(output.getName(), output.getDataType().toCatalogDataType()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ default FunctionSignature computePrecision(FunctionSignature signature) {
Expression floatLength = getArgument(1);
int scale;

if (floatLength.isLiteral() || (floatLength instanceof Cast && floatLength.child(0).isLiteral()
if ((floatLength.isLiteral() && floatLength.getDataType() instanceof Int32OrLessType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in what situation would scale does not have integer type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we do computePrecision, we do not finish compute signature. so type coercion do not apply. so its child could be any type literal

|| (floatLength instanceof Cast && floatLength.child(0).isLiteral()
&& floatLength.child(0).getDataType() instanceof Int32OrLessType)) {
// Scale argument is a literal or cast from other literal
if (floatLength instanceof Cast) {
Expand Down
10 changes: 0 additions & 10 deletions regression-test/suites/correctness_p0/test_cast_decimal.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ suite("test_cast_decimal") {
sql """select cast(32123.34212456734 as decimal(3,2));"""
contains "cast(32123.34212456734 as DECIMALV3(3, 2))"
}


sql """
set enable_nereids_planner=false;
"""

explain {
sql """select cast(32123.34212456734 as decimal(3,2));"""
contains "CAST(32123.34212456734 AS DECIMALV3(3, 2))"
}

sql """drop table if exists test_ttt"""
sql """create table test_ttt(big_key bigint)DISTRIBUTED BY HASH(big_key) BUCKETS 1 PROPERTIES ("replication_num" = "1");"""
Expand Down