CurtHagenlocher commented on code in PR #1317:
URL: https://github.com/apache/arrow-adbc/pull/1317#discussion_r1401132226


##########
csharp/src/Drivers/BigQuery/BigQueryConnection.cs:
##########
@@ -977,5 +979,115 @@ enum XdbcDataType
             XdbcDataType_XDBC_WCHAR = -8,
             XdbcDataType_XDBC_WVARCHAR = -9,
         }
+
+        private class EmptyArrayCreationVisitor :
+            IArrowTypeVisitor<BooleanType>,
+            IArrowTypeVisitor<FixedWidthType>,
+            IArrowTypeVisitor<BinaryType>,
+            IArrowTypeVisitor<StringType>,
+            IArrowTypeVisitor<ListType>,
+            IArrowTypeVisitor<FixedSizeListType>,
+            IArrowTypeVisitor<StructType>,
+            IArrowTypeVisitor<UnionType>,
+            IArrowTypeVisitor<MapType>
+        {
+            public ArrayData Result { get; private set; }
+            private readonly int _length;
+
+            public EmptyArrayCreationVisitor(int length)
+            {
+                _length = length;
+            }
+
+            public void Visit(BooleanType type)
+            {
+                Result = new ArrayData(type, _length, _length, 0, new[] { 
ArrowBuffer.Empty, ArrowBuffer.Empty });
+            }
+
+            public void Visit(FixedWidthType type)
+            {
+                Result = new ArrayData(type, _length, _length, 0, new[] { 
ArrowBuffer.Empty, ArrowBuffer.Empty });
+            }
+
+            public void Visit(BinaryType type)
+            {
+                Result = new ArrayData(type, _length, _length, 0, new[] { 
ArrowBuffer.Empty, ArrowBuffer.Empty, ArrowBuffer.Empty });
+            }
+
+            public void Visit(StringType type)
+            {
+                Result = new ArrayData(type, _length, _length, 0, new[] { 
ArrowBuffer.Empty, ArrowBuffer.Empty, ArrowBuffer.Empty });
+            }
+
+            public void Visit(ListType type)
+            {
+                type.ValueDataType.Accept(this);
+                ArrayData child = Result;
+
+                Result = new ArrayData(type, _length, _length, 0, new[] { 
ArrowBuffer.Empty }, new[] { child });
+            }
+
+            public void Visit(FixedSizeListType type)
+            {
+                type.ValueDataType.Accept(this);
+                ArrayData child = Result;
+
+                Result = new ArrayData(type, _length, _length, 0, new[] { 
ArrowBuffer.Empty }, new[] { child });
+            }
+
+            public void Visit(StructType type)
+            {
+                ArrayData[] children = new ArrayData[type.Fields.Count];
+                for (int i = 0; i < type.Fields.Count; i++)
+                {
+                    type.Fields[i].DataType.Accept(this);
+                    children[i] = Result;
+                }
+
+                Result = new ArrayData(type, _length, _length, 0, new[] { 
ArrowBuffer.Empty }, children);
+            }
+
+            public void Visit(UnionType type)
+            {
+                int bufferCount = type.Mode switch
+                {
+                    UnionMode.Sparse => 1,
+                    UnionMode.Dense => 2,
+                    _ => throw new InvalidOperationException("TODO"),
+                };
+
+                ArrayData[] children = new ArrayData[type.Fields.Count];
+                for (int i = 0; i < type.Fields.Count; i++)
+                {
+                    type.Fields[i].DataType.Accept(this);
+                    children[i] = Result;
+                }
+
+                ArrowBuffer[] buffers = new ArrowBuffer[bufferCount];
+                buffers[0] = ArrowBuffer.Empty;
+                if (bufferCount > 1)
+                {
+                    buffers[1] = ArrowBuffer.Empty;
+                }
+
+                Result = new ArrayData(type, _length, _length, 0, buffers, 
children);
+            }
+
+            public void Visit(MapType type)
+            {
+                ArrayData[] children = new ArrayData[2];
+                type.KeyField.DataType.Accept(this);
+                children[0] = Result;
+                type.ValueField.DataType.Accept(this);
+                children[1] = Result;
+
+                Result = new ArrayData(type, _length, _length, 0, new[] { 
ArrowBuffer.Empty }, children);
+            }
+
+            public void Visit(IArrowType type)
+            {
+                throw new NotImplementedException($"Concatenation for 
{type.Name} is not supported yet.");

Review Comment:
   Oops



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

Reply via email to