anoopj commented on code in PR #3080:
URL: https://github.com/apache/iceberg-rust/pull/3080#discussion_r3873791649


##########
crates/iceberg/src/arrow/value.rs:
##########
@@ -864,24 +864,24 @@ pub(crate) fn create_primitive_array_repeated(
         (DataType::Float64, Some(PrimitiveLiteral::Double(value))) => {
             Arc::new(Float64Array::from(vec![value.0; num_rows]))
         }
-        (DataType::Utf8, Some(PrimitiveLiteral::String(value))) => {
-            Arc::new(StringArray::from(vec![value.clone(); num_rows]))
-        }
-        (DataType::Binary, Some(PrimitiveLiteral::Binary(value))) => {
-            Arc::new(BinaryArray::from_vec(vec![value; num_rows]))
-        }
-        (DataType::LargeBinary, Some(PrimitiveLiteral::Binary(value))) => {
-            Arc::new(LargeBinaryArray::from_vec(vec![value; num_rows]))
-        }
-        (DataType::FixedSizeBinary(len), 
Some(PrimitiveLiteral::Binary(value))) => {
-            let repeated: Vec<&[u8]> = vec![value.as_slice(); num_rows];
-            
Arc::new(FixedSizeBinaryArray::try_from_iter(repeated.into_iter()).map_err(|e| {
-                Error::new(
-                    ErrorKind::DataInvalid,
-                    format!("Failed to create FixedSizeBinary({len}) array: 
{e}"),
-                )
-            })?)
-        }
+        (DataType::Utf8, Some(PrimitiveLiteral::String(value))) => Arc::new(
+            StringArray::from_iter_values(std::iter::repeat_n(value.as_str(), 
num_rows)),
+        ),
+        (DataType::Binary, Some(PrimitiveLiteral::Binary(value))) => Arc::new(
+            
BinaryArray::from_iter_values(std::iter::repeat_n(value.as_slice(), num_rows)),
+        ),
+        (DataType::LargeBinary, Some(PrimitiveLiteral::Binary(value))) => 
Arc::new(
+            
LargeBinaryArray::from_iter_values(std::iter::repeat_n(value.as_slice(), 
num_rows)),
+        ),
+        (DataType::FixedSizeBinary(len), 
Some(PrimitiveLiteral::Binary(value))) => Arc::new(
+            
FixedSizeBinaryArray::try_from_iter(std::iter::repeat_n(value.as_slice(), 
num_rows))

Review Comment:
   Thanks. I think both are valid findings and pre-existing as you noted. 
   
   >  Wrong-width literal
   
   I added a guard on `len` before `try_from_iter` so a mismatched-width 
literal errors with the constraint, and added a test. 
   
   > Empty batch
   
   I looked into `try_from_iter` in arrow 58.3. It doesn't come back as 
`FixedSizeBinary(0)`; it has an explicit `if len == 0 { return Err(""..) }` 
guard. So num_rows == 0 over a fixed[n] column surfaces as a hard `DataInvalid` 
error. So it's a loud failure. R
   
    I added a test that pins this "empty -> Err" behavior. 



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