HaoYang670 commented on code in PR #1904:
URL: https://github.com/apache/arrow-rs/pull/1904#discussion_r901066507


##########
arrow/src/record_batch.rs:
##########
@@ -160,20 +160,27 @@ impl RecordBatch {
             }
         };
 
-        // check that all columns match the schema
-        let not_match = columns
-            .iter()
-            .zip(schema.fields().iter())
-            .map(|(col, field)| (col.data_type(), field.data_type()))
-            .enumerate()
-            .find(type_not_match);
+        let is_all_nones = columns.iter().all(|x| {

Review Comment:
   > My personal preference would be to make the try_from_sparse_iter method 
take the length of the arrays as an argument, rather than adding workarounds in 
other parts of the codebase
   
   I personally agree with @tustvold. We could add an argument `value_len: 
Option<usize>`, such as (not tested):
   ```rust
       pub fn try_from_sparse_iter<T, U>(mut iter: T, value_len: Option<usize>) 
-> Result<Self>
       where
           T: Iterator<Item = Option<U>>,
           U: AsRef<[u8]>,
   ```
   And the function will return an error if `iter` is all-nones and `value_len` 
is None. Maybe we could return something such as (not tested):
   ```rust
   ArrowError::InvalidArgumentError("cannot determine the value length of the 
array")
   ```



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