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

[PR] feat(csharp/Client): Implement support for primary schema collections [arrow-adbc]

CurtHagenlocher opened a new pull request, #1317:
URL: https://github.com/apache/arrow-adbc/pull/1317

   Adds support for MetaDataCollection, Restrictions, Catalogs, Schemas, TableTypes, Tables and Columns.


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


Re: [PR] feat(csharp/Client): Implement support for primary schema collections [arrow-adbc]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1317:
URL: https://github.com/apache/arrow-adbc/pull/1317#issuecomment-1821331293

   :warning: Please follow the [Conventional Commits format in CONTRIBUTING.md](https://github.com/apache/arrow-adbc/blob/main/CONTRIBUTING.md) for PR titles.


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


Re: [PR] feat(csharp/Client): Implement support for primary schema collections [arrow-adbc]

Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher commented on code in PR #1317:
URL: https://github.com/apache/arrow-adbc/pull/1317#discussion_r1401132505


##########
csharp/src/Drivers/BigQuery/BigQueryInfoArrowStream.cs:
##########
@@ -28,25 +28,26 @@ namespace Apache.Arrow.Adbc.Drivers.BigQuery
     internal class BigQueryInfoArrowStream : IArrowArrayStream
     {
         private Schema schema;
-        private IEnumerable<IArrowArray> data;
-        private int length;
+        private RecordBatch batch;
 
-        public BigQueryInfoArrowStream(Schema schema, IEnumerable<IArrowArray> data, int length)
+        public BigQueryInfoArrowStream(Schema schema, List<IArrowArray> data)
         {
             this.schema = schema;
-            this.data = data;
-            this.length = length;
+            this.batch = new RecordBatch(schema, data, data[0].Length);
         }
 
         public Schema Schema { get { return this.schema; } }
 
         public ValueTask<RecordBatch> ReadNextRecordBatchAsync(CancellationToken cancellationToken = default)
         {
-            return new ValueTask<RecordBatch>(new RecordBatch(schema, data, length));
+            RecordBatch batch = this.batch;
+            this.batch = null;
+            return new ValueTask<RecordBatch>(batch);
         }
 
         public void Dispose()
         {
+            this.batch?.Dispose();

Review Comment:
   Should set batch to null



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


Re: [PR] feat(csharp/Client): Implement support for primary schema collections [arrow-adbc]

Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/Client): Implement support for primary schema collections [arrow-adbc]

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


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


Re: [PR] feat(csharp/Client): Implement support for primary schema collections [arrow-adbc]

Posted by "davidhcoe (via GitHub)" <gi...@apache.org>.
davidhcoe commented on PR #1317:
URL: https://github.com/apache/arrow-adbc/pull/1317#issuecomment-1821788955

   I verified these 


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