You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/10/05 19:30:15 UTC

[GitHub] [arrow] pgovind commented on a change in pull request #8348: ARROW-6972: [C#] C# support for StructArrays

pgovind commented on a change in pull request #8348:
URL: https://github.com/apache/arrow/pull/8348#discussion_r499823191



##########
File path: csharp/test/Apache.Arrow.Tests/ArrayBuilderTests.cs
##########
@@ -73,6 +73,67 @@ public void StringArrayBuilderHandlesNullsAndEmptyStrings()
             Assert.Equal(string.Empty, stringArray.GetString(3));
         }
 
+        [Fact]
+        public void TestStructArray()
+        {
+            // The following can be improved with a Builder class for StructArray.
+            List<Field> fields = new List<Field>();
+            Field.Builder fieldBuilder = new Field.Builder();
+            fields.Add(fieldBuilder.Name("Strings").DataType(StringType.Default).Nullable(true).Build());
+            fieldBuilder = new Field.Builder();
+            fields.Add(fieldBuilder.Name("Ints").DataType(Int32Type.Default).Nullable(true).Build());
+            StructType structType = new StructType(fields);
+
+            StringArray.Builder stringBuilder = new StringArray.Builder();
+            StringArray stringArray = stringBuilder.Append("joe").AppendNull().AppendNull().Append("mark").Build();
+            Int32Array.Builder intBuilder = new Int32Array.Builder();
+            Int32Array intArray = intBuilder.Append(1).Append(2).AppendNull().Append(4).Build();
+            List<Array> arrays = new List<Array>();
+            arrays.Add(stringArray);
+            arrays.Add(intArray);
+
+            ArrowBuffer.BitmapBuilder nullBitmap = new ArrowBuffer.BitmapBuilder();
+            var nullBitmapBuffer = nullBitmap.Append(true).Append(true).Append(false).Append(true).Build();
+            StructArray structs = new StructArray(structType, 4, arrays, nullBitmapBuffer, 1);
+
+            Assert.Equal(4, structs.Length);

Review comment:
       Replace the following asserts with ArrayComparer




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org