lidavidm commented on code in PR #3876:
URL: https://github.com/apache/arrow-adbc/pull/3876#discussion_r2680695464


##########
docs/source/format/connection_profiles.rst:
##########
@@ -0,0 +1,568 @@
+.. 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.
+
+==================================
+Driver Manager Connection Profiles
+==================================
+
+Overview
+========
+
+Similar to ODBC's ``odbc.ini``, the ADBC driver manager supports **connection 
profiles**

Review Comment:
   nit, but I think we should explain this as its own thing, and cite ODBC as 
an inspiration further down



##########
docs/source/format/connection_profiles.rst:
##########
@@ -0,0 +1,568 @@
+.. 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.
+
+==================================
+Driver Manager Connection Profiles
+==================================
+
+Overview
+========
+
+Similar to ODBC's ``odbc.ini``, the ADBC driver manager supports **connection 
profiles**
+that specify a driver and connection options in a reusable configuration. This 
allows users to:
+
+- Define connection information in files or environment variables
+- Share connection configurations across applications
+- Distribute standardized connection settings
+- Avoid hardcoding driver names and credentials in application code
+
+Profiles are loaded during ``AdbcDatabaseInit()`` before initializing the 
driver. Options
+from the profile are applied automatically but do not override options already 
set via ``AdbcDatabaseSetOption()``.
+
+Quick Start
+===========
+
+Using a Profile via URI
+-----------------------
+
+The simplest way to use a profile is through a URI:
+
+.. code-block:: c
+
+   AdbcDatabase database;
+   AdbcDatabaseNew(&database, &error);
+   AdbcDatabaseSetOption(&database, "uri", "profile://my_snowflake_prod", 
&error);
+   AdbcDatabaseInit(&database, &error);
+
+Using a Profile via Option
+---------------------------
+
+Alternatively, specify the profile name directly:
+
+.. code-block:: c
+
+   AdbcDatabase database;
+   AdbcDatabaseNew(&database, &error);
+   AdbcDatabaseSetOption(&database, "profile", "my_snowflake_prod", &error);
+   AdbcDatabaseInit(&database, &error);
+
+Profile File Format
+===================
+
+Filesystem-based profiles use TOML format with the following structure:
+
+.. code-block:: toml
+
+   version = 1
+   driver = "snowflake"
+
+   [options]
+   # String options
+   adbc.snowflake.sql.account = "mycompany"
+   adbc.snowflake.sql.warehouse = "COMPUTE_WH"
+   adbc.snowflake.sql.database = "PRODUCTION"
+   adbc.snowflake.sql.schema = "PUBLIC"
+
+   # Integer options
+   adbc.snowflake.sql.client_session_keep_alive_heartbeat_frequency = 3600
+
+   # Double options
+   adbc.snowflake.sql.client_timeout = 30.5
+
+   # Boolean options (converted to "true" or "false" strings)
+   adbc.snowflake.sql.client_session_keep_alive = true
+
+version
+-------
+
+- **Required**: Yes
+- **Type**: Integer
+- **Supported values**: ``1``
+
+The ``version`` field specifies the profile format version. Currently, only 
version 1 is supported.
+This will enable future changes while maintaining backward compatibility.
+
+driver
+------
+
+- **Required**: No
+- **Type**: String
+
+The ``driver`` field specifies which ADBC driver to load. This can be:
+
+- A driver name (e.g., ``"snowflake"``)
+- A path to a shared library (e.g., 
``"/usr/local/lib/libadbc_driver_snowflake.so"``)
+- A path to a driver manifest (e.g., ``"/etc/adbc/drivers/snowflake.toml"``)
+
+If omitted, the driver must be specified through other means (e.g., the 
``driver`` option or ``uri`` parameter).
+The driver will be loaded identically to if it was specified via 
``AdbcDatabaseSetOption("driver", "<driver>")``.
+For more detils, see :doc:`driver_manifests`.
+
+Options Section
+---------------
+
+The ``[options]`` section contains driver-specific configuration options. 
Options can be of the following types:
+
+**String values**
+   Applied using ``AdbcDatabaseSetOption()``
+
+   .. code-block:: toml
+
+      adbc.snowflake.sql.account = "mycompany"
+      adbc.snowflake.sql.warehouse = "COMPUTE_WH"
+
+**Integer values**
+   Applied using ``AdbcDatabaseSetOptionInt()``
+
+   .. code-block:: toml
+
+      adbc.snowflake.sql.client_session_keep_alive_heartbeat_frequency = 3600
+
+**Double values**
+   Applied using ``AdbcDatabaseSetOptionDouble()``
+
+   .. code-block:: toml
+
+      adbc.snowflake.sql.client_timeout = 30.5
+
+**Boolean values**
+   Converted to strings ``"true"`` or ``"false"`` and applied using 
``AdbcDatabaseSetOption()``
+
+   .. code-block:: toml
+
+      adbc.snowflake.sql.client_session_keep_alive = true
+
+Environment Variable Substitution
+----------------------------------
+
+Profile values can reference environment variables using the ``env_var()`` 
syntax:
+
+.. code-block:: toml
+
+   version = 1
+   driver = "adbc_driver_snowflake"
+
+   [options]
+   adbc.snowflake.sql.account = "env_var(SNOWFLAKE_ACCOUNT)"

Review Comment:
   Hmm. Why not use `option = { env_var = "NAME" }`?



##########
c/include/arrow-adbc/adbc_driver_manager.h:
##########
@@ -175,6 +175,183 @@ AdbcStatusCode 
AdbcDriverManagerDatabaseSetAdditionalSearchPathList(
 ADBC_EXPORT
 const char* AdbcStatusCodeMessage(AdbcStatusCode code);
 
+/// \defgroup adbc-driver-manager-connection-profile Connection Profiles
+/// Similar to odbc.ini, the ADBC driver manager can support "connection 
profiles"
+/// that specify a driver and options to use when connecting. This allows 
users to
+/// specify connection information in a file or environment variable, and have 
the
+/// driver manager load the appropriate driver and set options accordingly.
+///
+/// This allows creating reusable connection configurations for sharing and 
distribution
+/// without needing to hardcode driver names and options in application code. 
Profiles
+/// will be loaded during DatabaseInit before attempting to initialize the 
driver. Any
+/// options specified by the profile will be applied but will not override 
options
+/// that have already been set using DatabaseSetOption.
+///
+/// To facilitate customization, we define an interface for implementing a 
Connection
+/// Profile object along with a provider function definition which can be set 
into
+/// the driver manager to allow for customized profile loading.
+///
+/// A profile can be specified to the Driver Manager in one of two ways,
+/// which will invoke the profile provider during the call to DatabaseInit:
+///
+/// 1. The "profile" option can be set using DatabaseSetOption with the name 
of the
+/// profile to load.
+/// 2. The "uri" being used can have the form "profile://<profile>"
+///
+/// @{
+
+/// \brief Abstract interface for connection profile providers
+struct ADBC_EXPORT AdbcConnectionProfile {
+  /// \brief Opaque implementation-defined state.
+  /// This field is NULL if the profile is uninitialized/freed (but
+  /// it need not have a value even if the profile is initialized).
+  void* private_data;
+
+  /// \brief Release the profile and perform any cleanup.
+  void (*release)(struct AdbcConnectionProfile* profile);

Review Comment:
   (Does the manager call release or does the application?)



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