Reranko05 commented on code in PR #50945:
URL: https://github.com/apache/arrow/pull/50945#discussion_r3913508788


##########
python/pyarrow/tests/test_json.py:
##########
@@ -529,9 +528,13 @@ def test_non_linewise_chunker_bad_middle_block(self):
             'n': [1]
         }
 
-        with pytest.raises(pa.ArrowInvalid,
-                           match="JSON parse error *"):
+        try:
             reader.read_next_batch()
+        except pa.ArrowInvalid:
+            pass
+        else:
+            with pytest.raises(pa.ArrowInvalid):
+                reader.read_next_batch()

Review Comment:
   Done.



##########
cpp/src/arrow/json/reader_test.cc:
##########
@@ -758,20 +757,26 @@ TEST_P(StreamingReaderTest, 
PropagateErrorsNonLinewiseChunker) {
   AssertReadNext(reader, &batch);
   EXPECT_EQ(reader->bytes_processed(), 9);
   ASSERT_BATCHES_EQUAL(*RecordBatchFromJSON(test_schema, "[{\"i\":0}]"), 
*batch);
-  // Chunker doesn't require newline delimiters, so this should be valid
+
+  // The chunker doesn't require newline delimiters between records.
   AssertReadNext(reader, &batch);
   EXPECT_EQ(reader->bytes_processed(), 20);
   ASSERT_BATCHES_EQUAL(*RecordBatchFromJSON(test_schema, "[{\"i\":1}]"), 
*batch);
 
-  EXPECT_RAISES_WITH_MESSAGE_THAT(Invalid,
-                                  ::testing::StartsWith("Invalid: JSON parse 
error"),
-                                  reader->ReadNext(&batch));
-  EXPECT_EQ(reader->bytes_processed(), 20);
-  // Incoming chunker error from ":2}" shouldn't leak through after the first 
failure,
-  // which is a possibility if async tasks are still outstanding due to 
readahead.
+  // Depending on readahead, the malformed record may be reported by either
+  // the parser or the chunker on the next read.
+  auto status = reader->ReadNext(&batch);
+  if (status.ok()) {
+    status = reader->ReadNext(&batch);
+  }
+  ASSERT_FALSE(status.ok());
+  EXPECT_TRUE(status.IsInvalid());
+  EXPECT_THAT(status.ToStringWithoutContextLines(),
+              ::testing::AnyOf(::testing::StartsWith("Invalid: JSON parse 
error"),
+                               ::testing::StartsWith("Invalid: JSON chunk 
error")));

Review Comment:
   Addressed.



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

Reply via email to