abhishekagarwal87 commented on a change in pull request #12259:
URL: https://github.com/apache/druid/pull/12259#discussion_r815679114



##########
File path: 
core/src/main/java/org/apache/druid/data/input/IntermediateRowParsingReader.java
##########
@@ -155,6 +259,39 @@ public void close() throws IOException
    */
   protected abstract List<Map<String, Object>> toMap(T intermediateRow) throws 
IOException;
 
+  /**
+   * A helper method which enriches the base parse exception message with 
additional information. The returned message
+   * has a format: "baseExceptionMessage (key1: value1, key2: value2)" if 
additional properties are present. Else it
+   * returns the baseException message without any modification
+   */
+  private static String buildParseExceptionMessage(
+      @Nonnull String baseExceptionMessage,
+      @Nullable InputEntity source,
+      @Nullable Long recordNumber,
+      @Nullable Map<String, Object> metadata
+  )
+  {
+    StringBuilder sb = new StringBuilder();
+    if (source != null && source.getUri() != null) {
+      sb.append(StringUtils.format("Path: %s, ", source.getUri()));
+    }
+    if (recordNumber != null) {
+      sb.append(StringUtils.format("Record: %d, ", recordNumber));
+    }
+    if (metadata != null) {
+      metadata.entrySet().stream()
+              .map(entry -> StringUtils.format("%s: %s, ", entry.getKey(), 
entry.getValue().toString()))
+              .forEach(sb::append);
+    }
+    if (sb.length() == 0) {
+      return baseExceptionMessage;
+    }
+    sb.setLength(sb.length() - 2); // Erase the last stray ", "
+    sb.insert(0, " ("); // Wrap the additional information in brackets

Review comment:
       this can be costly. Instead, you can just return baseExceptionMessage + 
"(" +  sb + ")" 




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to