You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/06/12 09:56:57 UTC

[GitHub] [arrow-rs] tustvold opened a new pull request, #4400: StructBuilder validate child types (#4397)

tustvold opened a new pull request, #4400:
URL: https://github.com/apache/arrow-rs/pull/4400

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #4397
   
   # Rationale for this change
    
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


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


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #4400: StructBuilder validate child types (#4397)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4400:
URL: https://github.com/apache/arrow-rs/pull/4400#discussion_r1226400520


##########
arrow-array/src/builder/struct_builder.rs:
##########
@@ -240,42 +240,24 @@ impl StructBuilder {
     pub fn finish(&mut self) -> StructArray {
         self.validate_content();
 
-        let mut child_data = Vec::with_capacity(self.field_builders.len());
-        for f in &mut self.field_builders {
-            let arr = f.finish();
-            child_data.push(arr.to_data());
-        }
-        let length = self.len();
+        let arrays = self.field_builders.iter_mut().map(|f| f.finish()).collect();
         let nulls = self.null_buffer_builder.finish();
-
-        let builder = ArrayData::builder(DataType::Struct(self.fields.clone()))
-            .len(length)
-            .child_data(child_data)
-            .nulls(nulls);
-
-        let array_data = unsafe { builder.build_unchecked() };
-        StructArray::from(array_data)
+        StructArray::new(self.fields.clone(), arrays, nulls)

Review Comment:
   As ArrayBuilder doesn't expose a data_type we can't validate the builders eagerly, but we can at least verify on finish



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


[GitHub] [arrow-rs] tustvold merged pull request #4400: StructBuilder Validate Child Data (#4397)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold merged PR #4400:
URL: https://github.com/apache/arrow-rs/pull/4400


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


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #4400: StructBuilder validate child types (#4397)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4400:
URL: https://github.com/apache/arrow-rs/pull/4400#discussion_r1226406222


##########
arrow-array/src/builder/struct_builder.rs:
##########
@@ -305,8 +287,8 @@ mod tests {
         let int_builder = Int32Builder::new();
 
         let fields = vec![
-            Field::new("f1", DataType::Utf8, false),
-            Field::new("f2", DataType::Int32, false),
+            Field::new("f1", DataType::Utf8, true),

Review Comment:
   The builder will now also verify nullability



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