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

   This bit of code has been in the R bindings for a few months...I use it to 
make a few throwaway test drivers that make it easier to write self-contained 
tests in the adbcdrivermanager package. I'm wondering if moving it into 
`c/common` could help us move towards a common code base for the Postgres and 
SQLite drivers and lower the barrier for others to contribute drivers (or just 
copy `driver_base.h` and write/maintain it themselves somewhere else).
   
   ADBC drivers are beautifully simple things: if you can turn an `std::string` 
into an `ArrowArrayStream`, you have an ADBC driver. Unfortunately, there are a 
lot of boring details that are easy to get wrong between a would-be driver 
contributor and a fully functional ADBC driver. I see the "boring details that 
are easy to get wrong" are (1) remembering how to initialize the C callables in 
a drive, (2) options set/get (particularly with ADBC 1.1), and (3) error 
handling.
   
   The draft I've included here lets you implement the minimal driver I 
described above as:
   
   ```c
   class SimpleDatabase : public adbc::common::DatabaseObjectBase {};
   
   class SimpleConnection : public adbc::common::ConnectionObjectBase {};
   
   class SimpleStatement : public adbc::common::StatementObjectBase {
    public:
     AdbcStatusCode SetSqlQuery(const char* query, AdbcError* error) {
       sql_query_ = std::string(query);
       return ADBC_STATUS_OK;
     }
   
     AdbcStatusCode ExecuteQuery(ArrowArrayStream* stream, int64_t* 
rows_affected,
                                 AdbcError* error) {
       // Use sql_query_ to go do something
       return ADBC_STATUS_NOT_IMPLEMENTED;
     }
   
    private:
     std::string sql_query_;
   };
   
   using SimpleDriver =
       adbc::common::Driver<SimpleDatabase, SimpleConnection, SimpleStatement>;
   
   AdbcStatusCode SimpleDriverInitFunc(int version, void* raw_driver, 
AdbcError* error) {
     return SimpleDriver::Init(version, raw_driver, error);
   }
   ```
   
   I'm happy to redo anything about this (including refactor the 
Postgres/SQLite drivers to use it) but wanted to pause before going further to 
make sure we actually want to do this!


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