jihoonson commented on a change in pull request #10383:
URL: https://github.com/apache/druid/pull/10383#discussion_r504295781



##########
File path: 
core/src/main/java/org/apache/druid/data/input/IntermediateRowParsingReader.java
##########
@@ -96,23 +101,45 @@ public void close() throws IOException
   public CloseableIterator<InputRowListPlusRawValues> sample() throws 
IOException
   {
     return intermediateRowIterator().map(row -> {
-      final Map<String, Object> rawColumns;
+
+      final List<Map<String, Object>> rawColumnsList;
       try {
-        rawColumns = toMap(row);
+        rawColumnsList = toMap(row);
       }
       catch (Exception e) {
-        return InputRowListPlusRawValues.of(null, new ParseException(e, 
"Unable to parse row [%s] into JSON", row));
+        return Collections.singletonList(InputRowListPlusRawValues.of(null,
+                                                                      new 
ParseException(e, "Unable to parse row [%s] into JSON", row)));
+      }
+
+      if (CollectionUtils.isNullOrEmpty(rawColumnsList)) {
+        return Collections.singletonList(InputRowListPlusRawValues.of(null,
+                                                                      new 
ParseException("No map object parsed for row [%s]", row)));
       }
+
+      List<InputRow> rows;
       try {
-        return InputRowListPlusRawValues.of(parseInputRows(row), rawColumns);
+        rows = parseInputRows(row);
       }
       catch (ParseException e) {
-        return InputRowListPlusRawValues.of(rawColumns, e);
+        return rawColumnsList.stream().map(rawColumn -> 
InputRowListPlusRawValues.of(rawColumn, e)).collect(Collectors.toList());
       }
       catch (IOException e) {
-        return InputRowListPlusRawValues.of(rawColumns, new ParseException(e, 
"Unable to parse row [%s] into inputRow", row));
+        ParseException exception = new ParseException(e, "Unable to parse row 
[%s] into inputRow", row);
+        return rawColumnsList.stream().map(rawColumn -> 
InputRowListPlusRawValues.of(rawColumn, 
exception)).collect(Collectors.toList());
+      }

Review comment:
       Good point. I'm not sure if we have a unit test for parsing sampler 
response. If we have, the CI will fail and we need to fix it in this PR 
together. Otherwise, I'm OK with doing the fix in a follow-up. @vogievetsky do 
you know whether or not we have such a unit test?




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

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