fix(数据集): 修复SQL片段中特殊字符报错的问题

This commit is contained in:
junjun 2024-05-10 17:10:45 +08:00
parent e24b1aa4ae
commit ee585e8e5f

View File

@ -16,6 +16,7 @@ import org.apache.commons.collections4.MapUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import static org.apache.calcite.sql.SqlKind.*;
@ -143,7 +144,7 @@ public class SqlUtils {
public static String replaceTablePlaceHolder(String s, String placeholder) {
s = s.replaceAll("\r\n", " ")
.replaceAll("\n", " ")
.replaceAll(SqlPlaceholderConstants.TABLE_PLACEHOLDER_REGEX, placeholder)
.replaceAll(SqlPlaceholderConstants.TABLE_PLACEHOLDER_REGEX, Matcher.quoteReplacement(placeholder))
.replaceAll("ASYMMETRIC", "")
.replaceAll("SYMMETRIC", "");
return s;
@ -169,7 +170,7 @@ public class SqlUtils {
if (MapUtils.isNotEmpty(fieldsDialect)) {
for (Map.Entry<String, String> ele : fieldsDialect.entrySet()) {
s = s.replaceAll(SqlPlaceholderConstants.KEYWORD_PREFIX_REGEX + ele.getKey() + SqlPlaceholderConstants.KEYWORD_SUFFIX_REGEX, ele.getValue());
s = s.replaceAll(SqlPlaceholderConstants.KEYWORD_PREFIX_REGEX + ele.getKey() + SqlPlaceholderConstants.KEYWORD_SUFFIX_REGEX, Matcher.quoteReplacement(ele.getValue()));
}
}
return s;