This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 922cafb  Update dist/ for commit 
20e5bae8db24737857e725801d6a965ed21a4f7a
922cafb is described below

commit 922cafbc6d04ad58c0493025cbb61ca4219f8e09
Author: GitHub Actions <[email protected]>
AuthorDate: Thu Mar 30 13:56:44 2023 +0000

    Update dist/ for commit 20e5bae8db24737857e725801d6a965ed21a4f7a
---
 dist/nanoarrow.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/dist/nanoarrow.c b/dist/nanoarrow.c
index a6f7df2..4e5cc6c 100644
--- a/dist/nanoarrow.c
+++ b/dist/nanoarrow.c
@@ -2657,11 +2657,15 @@ ArrowErrorCode ArrowArrayViewValidateFull(struct 
ArrowArrayView* array_view,
 
   if (array_view->storage_type == NANOARROW_TYPE_DENSE_UNION ||
       array_view->storage_type == NANOARROW_TYPE_SPARSE_UNION) {
-    // Check that we have valid type ids
-    if (array_view->union_type_id_map == NULL ||
-        
_ArrowParsedUnionTypeIdsWillEqualChildIndices(array_view->union_type_id_map,
-                                                      array_view->n_children,
-                                                      array_view->n_children)) 
{
+    // Check that we have valid type ids.
+    if (array_view->union_type_id_map == NULL) {
+      // If the union_type_id map is NULL
+      // (e.g., when using ArrowArrayInitFromType() + 
ArrowArrayAllocateChildren()
+      // + ArrowArrayFinishBuilding()), we don't have enough information to 
validate
+      // this buffer (GH-178).
+    } else if (_ArrowParsedUnionTypeIdsWillEqualChildIndices(
+                   array_view->union_type_id_map, array_view->n_children,
+                   array_view->n_children)) {
       
NANOARROW_RETURN_NOT_OK(ArrowAssertRangeInt8(array_view->buffer_views[0], 0,
                                                    array_view->n_children - 1, 
error));
     } else {
@@ -2671,7 +2675,8 @@ ArrowErrorCode ArrowArrayViewValidateFull(struct 
ArrowArrayView* array_view,
     }
   }
 
-  if (array_view->storage_type == NANOARROW_TYPE_DENSE_UNION) {
+  if (array_view->storage_type == NANOARROW_TYPE_DENSE_UNION &&
+      array_view->union_type_id_map != NULL) {
     // Check that offsets refer to child elements that actually exist
     for (int64_t i = 0; i < array_view->array->length; i++) {
       int8_t child_id = ArrowArrayViewUnionChildIndex(array_view, i);

Reply via email to