birschick-bq commented on code in PR #1865: URL: https://github.com/apache/arrow-adbc/pull/1865#discussion_r1604027321
########## csharp/src/Apache.Arrow.Adbc/AdbcConnection11.cs: ########## @@ -0,0 +1,395 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Apache.Arrow.Ipc; + +namespace Apache.Arrow.Adbc +{ + /// <summary> + /// Provides methods for query execution, managing prepared statements, + /// using transactions, and so on. + /// </summary> + public abstract class AdbcConnection11 : IDisposable +#if NET5_0_OR_GREATER + , IAsyncDisposable +#endif + { + ~AdbcConnection11() => Dispose(false); + + /// <summary> + /// Attempts to cancel an in-progress operation on a connection. + /// </summary> + /// <remarks> + /// This can be called during a method like GetObjects or while consuming an ArrowArrayStream + /// returned from such. Calling this function should make the other function throw a cancellation exception. + /// + /// This must always be thread-safe. + /// </remarks> + public virtual void Cancel() + { + throw AdbcException.NotImplemented("Connection does not support cancellation"); + } + + /// <summary> + /// Starts a new transaction with the given isolation level + /// </summary> + /// <param name="isolationLevel">The isolation level for the new transaction.</param> + public virtual void BeginTransaction(IsolationLevel? isolationLevel = default) + { + Task.Run(() => BeginTransactionAsync(isolationLevel)).GetAwaiter().GetResult(); + } + + public virtual Task BeginTransactionAsync(IsolationLevel? isolationLevel = default, CancellationToken cancellationToken = default) Review Comment: nit: missing documentation for Async method. ########## csharp/src/Apache.Arrow.Adbc/AdbcConnection11.cs: ########## @@ -0,0 +1,395 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Apache.Arrow.Ipc; + +namespace Apache.Arrow.Adbc +{ + /// <summary> + /// Provides methods for query execution, managing prepared statements, + /// using transactions, and so on. + /// </summary> + public abstract class AdbcConnection11 : IDisposable +#if NET5_0_OR_GREATER + , IAsyncDisposable +#endif + { + ~AdbcConnection11() => Dispose(false); + + /// <summary> + /// Attempts to cancel an in-progress operation on a connection. + /// </summary> + /// <remarks> + /// This can be called during a method like GetObjects or while consuming an ArrowArrayStream + /// returned from such. Calling this function should make the other function throw a cancellation exception. + /// + /// This must always be thread-safe. + /// </remarks> + public virtual void Cancel() + { + throw AdbcException.NotImplemented("Connection does not support cancellation"); + } + + /// <summary> + /// Starts a new transaction with the given isolation level + /// </summary> + /// <param name="isolationLevel">The isolation level for the new transaction.</param> + public virtual void BeginTransaction(IsolationLevel? isolationLevel = default) + { + Task.Run(() => BeginTransactionAsync(isolationLevel)).GetAwaiter().GetResult(); + } + + public virtual Task BeginTransactionAsync(IsolationLevel? isolationLevel = default, CancellationToken cancellationToken = default) + { + throw AdbcException.NotImplemented("Connection does not support transactions"); + } + + /// <summary> + /// Create a new statement to bulk insert into a table. + /// </summary> + /// <param name="targetCatalog">The catalog name, or null to use the current catalog</param> + /// <param name="targetDbSchema">The schema name, or null to use the current schema</param> + /// <param name="targetTableName">The table name</param> + /// <param name="mode">The ingest mode</param> + /// <param name="isTemporary">True for a temporary table. Catalog and Schema must be null when true.</param> + public virtual AdbcStatement11 BulkIngest(string? targetCatalog, string? targetDbSchema, string targetTableName, BulkIngestMode mode, bool isTemporary) + { + throw AdbcException.NotImplemented("Connection does not support BulkIngest"); + } + + /// <summary> + /// Commit the pending transaction. + /// </summary> + public virtual void Commit() + { + Task.Run(() => CommitAsync()).GetAwaiter().GetResult(); + } + + /// <summary> + /// Commit the pending transaction. + /// </summary> + public virtual Task CommitAsync(CancellationToken cancellationToken = default) + { + throw AdbcException.NotImplemented("Connection does not support transactions"); + } + + /// <summary> + /// Create a new statement that can be executed. + /// </summary> + public abstract AdbcStatement11 CreateStatement(IReadOnlyDictionary<string, object>? options = default); + + /// <summary> + /// Get metadata about the driver/database. + /// </summary> + /// <param name="codes">The metadata items to fetch.</param> + /// <returns>Metadata about the driver and/or database</returns> + public virtual IArrowArrayStream GetInfo(ReadOnlySpan<AdbcInfoCode> codes) + { + var codesArray = codes.ToArray(); + return Task.Run(() => GetInfoAsync(codesArray)).GetAwaiter().GetResult(); + } + + /// <summary> + /// Get metadata about the driver/database. + /// </summary> + /// <param name="codes">The metadata items to fetch.</param> + /// <returns>Metadata about the driver and/or database</returns> + public virtual Task<IArrowArrayStream> GetInfoAsync(ReadOnlySpan<AdbcInfoCode> codes, CancellationToken cancellationToken = default) + { + throw AdbcException.NotImplemented("Connection does not support GetInfo"); + } + + /// <summary> + /// Get a hierarchical view of all catalogs, database schemas, tables, + /// and columns. + /// </summary> + /// <param name="depth"> + /// The level of nesting to display. + /// If ALL, display all levels (up through columns). + /// If CATALOGS, display only catalogs (i.e., catalog_schemas will be + /// null), and so on. May be a* search pattern. Review Comment: ```suggestion /// null), and so on. May be a search pattern. ``` ########## csharp/src/Apache.Arrow.Adbc/AdbcConnection11.cs: ########## @@ -0,0 +1,395 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Apache.Arrow.Ipc; + +namespace Apache.Arrow.Adbc +{ + /// <summary> + /// Provides methods for query execution, managing prepared statements, + /// using transactions, and so on. + /// </summary> + public abstract class AdbcConnection11 : IDisposable +#if NET5_0_OR_GREATER + , IAsyncDisposable +#endif + { + ~AdbcConnection11() => Dispose(false); + + /// <summary> + /// Attempts to cancel an in-progress operation on a connection. + /// </summary> + /// <remarks> + /// This can be called during a method like GetObjects or while consuming an ArrowArrayStream + /// returned from such. Calling this function should make the other function throw a cancellation exception. + /// + /// This must always be thread-safe. + /// </remarks> + public virtual void Cancel() + { + throw AdbcException.NotImplemented("Connection does not support cancellation"); + } + + /// <summary> + /// Starts a new transaction with the given isolation level + /// </summary> + /// <param name="isolationLevel">The isolation level for the new transaction.</param> + public virtual void BeginTransaction(IsolationLevel? isolationLevel = default) + { + Task.Run(() => BeginTransactionAsync(isolationLevel)).GetAwaiter().GetResult(); + } + + public virtual Task BeginTransactionAsync(IsolationLevel? isolationLevel = default, CancellationToken cancellationToken = default) + { + throw AdbcException.NotImplemented("Connection does not support transactions"); + } + + /// <summary> + /// Create a new statement to bulk insert into a table. + /// </summary> + /// <param name="targetCatalog">The catalog name, or null to use the current catalog</param> + /// <param name="targetDbSchema">The schema name, or null to use the current schema</param> + /// <param name="targetTableName">The table name</param> + /// <param name="mode">The ingest mode</param> + /// <param name="isTemporary">True for a temporary table. Catalog and Schema must be null when true.</param> + public virtual AdbcStatement11 BulkIngest(string? targetCatalog, string? targetDbSchema, string targetTableName, BulkIngestMode mode, bool isTemporary) + { + throw AdbcException.NotImplemented("Connection does not support BulkIngest"); + } + + /// <summary> + /// Commit the pending transaction. + /// </summary> + public virtual void Commit() + { + Task.Run(() => CommitAsync()).GetAwaiter().GetResult(); + } + + /// <summary> + /// Commit the pending transaction. + /// </summary> + public virtual Task CommitAsync(CancellationToken cancellationToken = default) + { + throw AdbcException.NotImplemented("Connection does not support transactions"); + } + + /// <summary> + /// Create a new statement that can be executed. + /// </summary> + public abstract AdbcStatement11 CreateStatement(IReadOnlyDictionary<string, object>? options = default); + + /// <summary> + /// Get metadata about the driver/database. + /// </summary> + /// <param name="codes">The metadata items to fetch.</param> + /// <returns>Metadata about the driver and/or database</returns> + public virtual IArrowArrayStream GetInfo(ReadOnlySpan<AdbcInfoCode> codes) + { + var codesArray = codes.ToArray(); + return Task.Run(() => GetInfoAsync(codesArray)).GetAwaiter().GetResult(); + } + + /// <summary> + /// Get metadata about the driver/database. + /// </summary> + /// <param name="codes">The metadata items to fetch.</param> + /// <returns>Metadata about the driver and/or database</returns> + public virtual Task<IArrowArrayStream> GetInfoAsync(ReadOnlySpan<AdbcInfoCode> codes, CancellationToken cancellationToken = default) + { + throw AdbcException.NotImplemented("Connection does not support GetInfo"); + } + + /// <summary> + /// Get a hierarchical view of all catalogs, database schemas, tables, + /// and columns. + /// </summary> + /// <param name="depth"> + /// The level of nesting to display. + /// If ALL, display all levels (up through columns). + /// If CATALOGS, display only catalogs (i.e., catalog_schemas will be + /// null), and so on. May be a* search pattern. + /// </param> + /// <param name="catalogPattern"> + /// Only show tables in the given catalog. + /// If null, do not filter by catalog.If an empty string, only show tables + /// without a catalog. May be a search pattern. + /// </param> + /// <param name="dbSchemaPattern"> + /// Only show tables in the given database schema. If null, do not + /// filter by database schema.If an empty string, only show tables + /// without a database schema. May be a search pattern. + /// </param> + /// <param name="tableNamePattern"> + /// Only show tables with the given name. If an empty string, only + /// show tables without a catalog. May be a search pattern. + /// </param> + /// <param name="tableTypes"> + /// Only show tables matching one of the given table types. + /// If null, show tables of any type. Valid table types can be + /// fetched from <see cref="GetTableTypes"/>}. + /// </param> + /// <param name="columnNamePattern"> + /// Only show columns with the given name. + /// If null, do not filter by name.May be a search pattern. + /// </param> + public virtual IArrowArrayStream GetObjects( + AdbcConnection.GetObjectsDepth depth, + string? catalogPattern, + string? dbSchemaPattern, + string? tableNamePattern, + IReadOnlyList<string>? tableTypes, + string? columnNamePattern) + { + return Task.Run(() => GetObjectsAsync(depth, catalogPattern, dbSchemaPattern, tableNamePattern, tableTypes, columnNamePattern)).GetAwaiter().GetResult(); + } + + /// <summary> + /// Get a hierarchical view of all catalogs, database schemas, tables, + /// and columns. + /// </summary> + /// <param name="depth"> + /// The level of nesting to display. + /// If ALL, display all levels (up through columns). + /// If CATALOGS, display only catalogs (i.e., catalog_schemas will be + /// null), and so on. May be a* search pattern. Review Comment: ```suggestion /// null), and so on. May be a search pattern. ``` -- 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]
