Skip to content

[fix](Nereids) fix double literal to string literal cast problem #49416

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

Merged
merged 5 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -261,8 +261,14 @@ protected Expression uncheckedCastTo(DataType targetType) throws AnalysisExcepti
return new CharLiteral(desc, ((CharType) targetType).getLen());
}
} else if (targetType.isVarcharType()) {
if (this.dataType.isDoubleType()) {
return new VarcharLiteral(desc.replaceAll("\\.0+$", ""), ((VarcharType) targetType).getLen());
}
return new VarcharLiteral(desc, ((VarcharType) targetType).getLen());
} else if (targetType instanceof StringType) {
if (this.dataType.isDoubleType()) {
return new StringLiteral(desc.replaceAll("\\.0+$", ""));
}
return new StringLiteral(desc);
} else if (targetType.isDateType()) {
return new DateLiteral(desc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1723,5 +1723,9 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select split_by_string('a😁a😁a', '')")
testFoldConst("select character_length('a😁a😁a')")
testFoldConst("select replace_empty('a😁a😁a', '', '2')")

// bug_fix
testFoldConst("select concat(substr('2025-03-20',1,4)-1,'-01-01')")
testFoldConst("select cast(2025.00 as string)")
}

Loading