Skip to content

Commit

Permalink
[Optimization-849][client,executor] Replace sql separator and change …
Browse files Browse the repository at this point in the history
…default sql separator into ;\n (DataLinkDC#850)

Co-authored-by: wenmo <32723967+wenmo@users.noreply.github.com>
  • Loading branch information
aiwenmo and aiwenmo authored Aug 9, 2022
1 parent f713e0a commit 9649108
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void submit(Integer id, DBConfig dbConfig) {
if (Asserts.isNotNullString(envId)) {
sb.append(envId);
}
sb.append("\r\n");
sb.append("\n");
}
sb.append(getFlinkSQLStatement(id, dbConfig));
List<String> statements = Submiter.getStatements(sb.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class FlinkQuery {

public static String separator() {
return ";\r\n";
return ";\n";
}

public static String defaultCatalog() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static SystemConfiguration getInstances() {
"sqlSeparator",
"FlinkSQL语句分割符",
ValueType.STRING,
";\r\n|;\n",
";\n",
"Flink SQL 的语句分割符"
);

Expand Down
6 changes: 4 additions & 2 deletions dlink-common/src/main/java/com/dlink/utils/SqlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static String[] getStatements(String sql, String sqlSeparator) {
return new String[0];
}

String[] splits = sql.split(sqlSeparator);
String[] splits = sql.replaceAll(";\r\n",";\n").split(sqlSeparator);
String lastStatement = splits[splits.length - 1].trim();
if (lastStatement.endsWith(SEMICOLON)){
splits[splits.length - 1] = lastStatement.substring(0,lastStatement.length()-1);
Expand All @@ -48,7 +48,9 @@ public static String[] getStatements(String sql, String sqlSeparator) {

public static String removeNote(String sql) {
if (Asserts.isNotNullString(sql)) {
sql = sql.replaceAll("\u00A0", " ").replaceAll("--([^'\r\n]{0,}('[^'\r\n]{0,}'){0,1}[^'\r\n]{0,}){0,}", "").replaceAll("[\r\n]+", "\r\n").trim();
sql = sql.replaceAll("\u00A0", " ")
.replaceAll("[\r\n]+", "\n")
.replaceAll("--([^'\n]{0,}('[^'\n]{0,}'){0,1}[^'\n]{0,}){0,}", "").trim();
}
return sql;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface FlinkSQLConstant {
/**
* 分隔符
*/
String SEPARATOR = ";";
String SEPARATOR = ";\n";
/**
* DDL 类型
*/
Expand Down

0 comments on commit 9649108

Please sign in to comment.