xbkaishui commented on a change in pull request #930:
URL:
https://github.com/apache/incubator-seatunnel/pull/930#discussion_r780591608
##########
File path:
seatunnel-core/seatunnel-core-sql/src/main/java/org/apache/seatunnel/core/sql/splitter/SqlStatementSplitter.java
##########
@@ -50,31 +54,32 @@
List<String> statements = new ArrayList<>();
List<String> buffer = new ArrayList<>();
- for (String line : content.split("\n")) {
+ for (String line : content.split(LINE_SEPARATOR)) {
if (isEndOfStatement(line)) {
buffer.add(line);
- statements.add(normalizeLine(buffer));
+ statements.addAll(normalizeLine(buffer));
buffer.clear();
} else {
buffer.add(line);
}
}
if (!buffer.isEmpty()) {
- statements.add(normalizeLine(buffer));
+ statements.addAll(normalizeLine(buffer));
}
return statements;
}
/**
* Remove comment lines.
*/
- private static String normalizeLine(List<String> buffer) {
- return buffer.stream()
- .map(statementLine ->
statementLine.replaceAll(BEGINNING_COMMENT_MASK, ""))
- .collect(Collectors.joining("\n"));
+ private static List<String> normalizeLine(List<String> buffer) {
+ String sqls = buffer.stream()
+ .map(statementLine ->
statementLine.replaceAll(BEGINNING_COMMENT_MASK, EMPTY_STR))
+ .collect(Collectors.joining(LINE_SEPARATOR));
+ return Arrays.asList(sqls.split(SEMICOLON));
Review comment:
ok, is it better to use flink sql parser to split sqls ? current logic
is not concise
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]