You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/01/05 05:13:14 UTC

[GitHub] [incubator-seatunnel] xbkaishui commented on a change in pull request #930: [SeaTunnel #783][UT] Add SqlStatementSplitter test case

xbkaishui commented on a change in pull request #930:
URL: https://github.com/apache/incubator-seatunnel/pull/930#discussion_r778550817



##########
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) {

Review comment:
       please see test case, normalizeStatementsWithMultiSqls, if mult sql in one lines, it will wrong to return one string  




-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org