felipecrv commented on code in PR #3714:
URL: https://github.com/apache/arrow-adbc/pull/3714#discussion_r2566820798


##########
rust/core/src/non_blocking.rs:
##########
@@ -0,0 +1,470 @@
+use arrow_array::{RecordBatch, RecordBatchReader};
+use arrow_schema::Schema;
+
+use std::collections::HashSet;
+use std::future::Future;
+
+use crate::error::Result;
+use crate::options::{self, *};
+use crate::PartitionedResult;
+
+/// Ability to configure an object by setting/getting options.
+pub trait AsyncOptionable {
+    type Option: AsRef<str> + Send;
+
+    /// Set a post-init option.
+    fn set_option(
+        &mut self,
+        key: Self::Option,
+        value: OptionValue,
+    ) -> impl Future<Output = Result<()>> + Send;
+
+    /// Get a string option value by key.
+    fn get_option_string(&self, key: Self::Option) -> impl Future<Output = 
Result<String>>;
+
+    /// Get a bytes option value by key.
+    fn get_option_bytes(&self, key: Self::Option) -> impl Future<Output = 
Result<Vec<u8>>>;
+
+    /// Get an integer option value by key.
+    fn get_option_int(&self, key: Self::Option) -> impl Future<Output = 
Result<i64>>;
+
+    /// Get a float option value by key.
+    fn get_option_double(&self, key: Self::Option) -> impl Future<Output = 
Result<f64>>;
+}
+
+/// A handle to an async ADBC driver.
+pub trait AsyncDriver {
+    type DatabaseType: AsyncDatabase + Send;
+
+    /// Allocate and initialize a new database without pre-init options.
+    fn new_database(&mut self) -> impl Future<Output = 
Result<Self::DatabaseType>> + Send;
+
+    /// Allocate and initialize a new database with pre-init options.
+    fn new_database_with_opts(
+        &mut self,
+        opts: Vec<(options::OptionDatabase, OptionValue)>,
+    ) -> impl Future<Output = Result<Self::DatabaseType>> + Send;
+}
+
+/// A handle to an async ADBC database.
+///
+/// Databases hold state shared by multiple connections. This typically means
+/// configuration and caches. For in-memory databases, it provides a place to
+/// hold ownership of the in-memory database.
+///
+/// Databases must be kept alive as long as any connections exist.
+pub trait AsyncDatabase: AsyncOptionable<Option = OptionDatabase> {
+    type ConnectionType: AsyncConnection + Send;
+
+    /// Allocate and initialize a new connection without pre-init options.
+    fn new_connection(&self) -> impl Future<Output = 
Result<Self::ConnectionType>> + Send;
+
+    /// Allocate and initialize a new connection with pre-init options.
+    fn new_connection_with_opts(
+        &self,
+        opts: Vec<(options::OptionConnection, OptionValue)>,
+    ) -> impl Future<Output = Result<Self::ConnectionType>> + Send;
+}
+
+/// A handle to an async ADBC connection.
+///
+/// Connections provide methods for query execution, managing prepared
+/// statements, using transactions, and so on.
+///
+/// # Autocommit
+///
+/// Connections should start in autocommit mode. They can be moved out by
+/// setting [options::OptionConnection::AutoCommit] to "false". Turning off
+/// autocommit allows customizing the isolation level.
+pub trait AsyncConnection: AsyncOptionable<Option = OptionConnection> {
+    type StatementType: AsyncStatement + Send;
+
+    /// Allocate and initialize a new statement.
+    fn new_statement(&mut self) -> impl Future<Output = 
Result<Self::StatementType>> + Send;
+
+    /// Cancel the in-progress operation on a connection.
+    fn cancel(&mut self) -> impl Future<Output = Result<()>> + Send;
+
+    /// Get metadata about the database/driver.
+    ///
+    /// # Arguments
+    ///
+    /// - `codes` - Requested metadata. If `None`, retrieve all available 
metadata.
+    ///
+    /// # Result
+    ///
+    /// The result is an Arrow dataset with the following schema:
+    ///
+    /// Field Name                  | Field Type
+    /// ----------------------------|------------------------
+    /// info_name                   | uint32 not null
+    /// info_value                  | INFO_SCHEMA
+    ///
+    /// INFO_SCHEMA is a dense union with members:
+    ///
+    /// Field Name (Type Code)      | Field Type
+    /// ----------------------------|------------------------
+    /// string_value (0)            | utf8
+    /// bool_value (1)              | bool
+    /// int64_value (2)             | int64
+    /// int32_bitmask (3)           | int32
+    /// string_list (4)             | list\<utf8\>
+    /// int32_to_int32_list_map (5) | map\<int32, list\<int32\>\>
+    fn get_info(
+        &self,
+        codes: Option<HashSet<options::InfoCode>>,
+    ) -> impl Future<Output = Result<impl RecordBatchReader + Send>>;

Review Comment:
   We can't bring datafusion into ADBC core :)



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