[fix](Nereids): Preserve "" in single quote strings and '' in double quote strings. (#27959)

This commit is contained in:
谢健
2023-12-05 12:30:03 +08:00
committed by GitHub
parent 358d73a0ae
commit 2f63999066
5 changed files with 23 additions and 10 deletions

View File

@ -1935,7 +1935,13 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
public Literal visitStringLiteral(StringLiteralContext ctx) {
String txt = ctx.STRING_LITERAL().getText();
String s = txt.substring(1, txt.length() - 1);
s = s.replace("''", "'").replace("\"\"", "\"");
if (txt.charAt(0) == '\'') {
// for single quote string, '' should be converted to '
s = s.replace("''", "'");
} else if (txt.charAt(0) == '"') {
// for double quote string, "" should be converted to "
s = s.replace("\"\"", "\"");
}
if (!SqlModeHelper.hasNoBackSlashEscapes()) {
s = LogicalPlanBuilderAssistant.escapeBackSlash(s);
}

View File

@ -789,8 +789,7 @@ public class StatisticsUtil {
return null;
}
return str.replace("'", "''")
.replace("\\", "\\\\")
.replace("\"", "\"\"");
.replace("\\", "\\\\");
}
public static boolean isExternalTable(String catalogName, String dbName, String tblName) {