talatuyarer commented on code in PR #36322:
URL: https://github.com/apache/beam/pull/36322#discussion_r2389911262
##########
sdks/java/extensions/sql/jdbc/src/test/java/org/apache/beam/sdk/extensions/sql/jdbc/BeamSqlLineTestingUtils.java:
##########
@@ -49,13 +49,40 @@ public static List<List<String>>
toLines(ByteArrayOutputStream outputStream) {
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
- return
outputLines.stream().map(BeamSqlLineTestingUtils::splitFields).collect(toList());
+ return outputLines.stream()
+ .map(BeamSqlLineTestingUtils::parseSqllineOutput)
+ .filter(line -> !line.isEmpty())
+ .collect(toList());
}
- private static List<String> splitFields(String outputLine) {
- return Arrays.stream(outputLine.split("\\|"))
- .map(field -> field.trim())
- .filter(field -> field.length() != 0)
- .collect(toList());
+ private static List<String> parseSqllineOutput(String outputLine) {
+ // Handle sqlline 1.12 table format with borders like +--+, | |, etc.
+ String trimmed = outputLine.trim();
+
+ // Skip table borders and empty lines
+ if (trimmed.isEmpty() || trimmed.matches("^[+\\-|\\s]+$")) {
+ return Arrays.asList();
+ }
+
+ // Parse data rows that contain actual values
+ if (trimmed.startsWith("|") && trimmed.endsWith("|")) {
+ // Remove the outer | characters and split by |
+ String content = trimmed.substring(1, trimmed.length() - 1);
+ return Arrays.stream(content.split("\\|"))
+ .map(field -> field.trim())
+ .filter(field -> !field.isEmpty())
+ .collect(toList());
+ }
+
+ // For non-table format, try the old parsing method
+ if (trimmed.contains("|")) {
+ return Arrays.stream(trimmed.split("\\|"))
+ .map(field -> field.trim())
+ .filter(field -> !field.isEmpty())
+ .collect(toList());
+ }
+
+ // Single value or non-table format (trimmed is not empty at this point)
+ return Arrays.asList(trimmed);
}
Review Comment:
Done
##########
sdks/java/extensions/sql/jdbc/src/main/java/org/apache/beam/sdk/extensions/sql/jdbc/BeamSqlLine.java:
##########
@@ -53,6 +53,17 @@ private static String[] checkConnectionArgs(String[] args) {
argsList.add(CONNECT_STRING_PREFIX);
}
+ // Add default credentials to prevent interactive prompts
+ if (!argsList.contains("-n")) {
+ argsList.add("-n");
+ argsList.add("beam");
+ }
+
+ if (!argsList.contains("-p")) {
+ argsList.add("-p");
+ argsList.add("beam");
+ }
Review Comment:
Done
--
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]