You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2023/01/12 07:50:32 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3399: Make JSON Decoder Continue After Error

tustvold commented on code in PR #3399:
URL: https://github.com/apache/arrow-rs/pull/3399#discussion_r1067798452


##########
arrow-json/src/reader.rs:
##########
@@ -677,17 +689,29 @@ impl Decoder {
     ///
     /// Returns `None` if the input iterator is exhausted.
     pub fn next_batch<I>(
-        &self,
+        &mut self,
         value_iter: &mut I,
     ) -> Result<Option<RecordBatch>, ArrowError>
     where
         I: Iterator<Item = Result<Value, ArrowError>>,
     {
+        if let Some(ref s) = self.error_json {
+            let msg = s.clone();
+            self.error_json = None;
+            return Err(ArrowError::JsonError(msg));
+        }
         let batch_size = self.options.batch_size;
         let mut rows: Vec<Value> = Vec::with_capacity(batch_size);
 
         for value in value_iter.by_ref().take(batch_size) {
-            let v = value?;
+            let v = match value {
+                Ok(v) => v,
+                Err(ArrowError::JsonError(s)) => {

Review Comment:
   I think this also needs `if !values.is_empty()` to avoid returning an empty batch



-- 
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: github-unsubscribe@arrow.apache.org

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