vustef commented on code in PR #1824:
URL: https://github.com/apache/iceberg-rust/pull/1824#discussion_r2517751158


##########
crates/iceberg/src/arrow/record_batch_transformer.rs:
##########
@@ -452,6 +515,33 @@ impl RecordBatchTransformer {
             }
         })
     }
+
+    /// Converts a PrimitiveLiteral to its corresponding Arrow DataType.
+    /// This is used for virtual fields to determine the Arrow type based on 
the constant value.
+    fn primitive_literal_to_arrow_type(literal: &PrimitiveLiteral) -> 
Result<DataType> {
+        Ok(match literal {
+            PrimitiveLiteral::Boolean(_) => DataType::Boolean,
+            PrimitiveLiteral::Int(_) => DataType::Int32,
+            PrimitiveLiteral::Long(_) => DataType::Int64,
+            PrimitiveLiteral::Float(_) => DataType::Float32,
+            PrimitiveLiteral::Double(_) => DataType::Float64,
+            PrimitiveLiteral::String(_) => {
+                // Use Run-End Encoding for constant strings (memory efficient)
+                let run_ends_field = Arc::new(Field::new("run_ends", 
DataType::Int32, false));
+                let values_field = Arc::new(Field::new("values", 
DataType::Utf8, true));

Review Comment:
   We can be more specific, e.g.:
   ```
   // Note: values field is nullable to match what RunArray::try_new(..) 
expects.
   ```



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