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

[PR] refactor(r/adbcdrivermanager): Use C++ base driver to implement test drivers [arrow-adbc]

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

   Now that there is a driver helper, we can simplify the implementation of two more test drivers. This required adding the rest of the methods to the driver helper as well. I also
   
   - Added `adbc_statement_cancel()`, which I'd missed in a previous PR
   - Fixed error handling for several methods, from which errors had been being ignored
   - Improved testing of the log driver, which only had coverage on a few of its methods


-- 
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] refactor(r/adbcdrivermanager): Use C++ base driver to implement test drivers [arrow-adbc]

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

   Thank you for taking a look! These are exactly the level of review I was hoping for!


-- 
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] refactor(r/adbcdrivermanager): Use C++ base driver to implement test drivers [arrow-adbc]

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


##########
r/adbcdrivermanager/src/driver_test.cc:
##########
@@ -0,0 +1,280 @@
+// 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.
+
+#define R_NO_REMAP
+#include <R.h>
+#include <Rinternals.h>
+
+#include <cstring>
+
+#include "driver_base.h"
+
+#include <adbc.h>
+
+using adbc::r::Option;
+
+using VoidDriver =
+    adbc::r::Driver<adbc::r::DatabaseObjectBase, adbc::r::ConnectionObjectBase,
+                    adbc::r::StatementObjectBase>;
+
+static AdbcStatusCode VoidDriverInitFunc(int version, void* raw_driver,
+                                         AdbcError* error) {
+  return VoidDriver::Init(version, raw_driver, error);
+}
+
+extern "C" SEXP RAdbcVoidDriverInitFunc(void) {
+  SEXP xptr =
+      PROTECT(R_MakeExternalPtrFn((DL_FUNC)VoidDriverInitFunc, R_NilValue, R_NilValue));
+  Rf_setAttrib(xptr, R_ClassSymbol, Rf_mkString("adbc_driver_init_func"));
+  UNPROTECT(1);
+  return xptr;
+}
+
+class MonkeyDriverStatement : public adbc::r::StatementObjectBase {
+ public:
+  MonkeyDriverStatement() { stream_.release = nullptr; }
+
+  ~MonkeyDriverStatement() {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);
+    }
+  }
+
+  AdbcStatusCode BindStream(ArrowArrayStream* stream, AdbcError* error) {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);
+    }
+
+    std::memcpy(&stream_, stream, sizeof(ArrowArrayStream));
+    stream->release = nullptr;
+    return ADBC_STATUS_OK;
+  }
+
+  AdbcStatusCode ExecuteQuery(ArrowArrayStream* stream, int64_t* rows_affected,
+                              AdbcError* error) {
+    if (stream != nullptr) {
+      std::memcpy(stream, &stream_, sizeof(ArrowArrayStream));
+      stream_.release = nullptr;
+    }
+
+    *rows_affected = -1;
+    return ADBC_STATUS_OK;
+  }
+
+ private:
+  ArrowArrayStream stream_;
+};
+
+using MonkeyDriver =
+    adbc::r::Driver<adbc::r::DatabaseObjectBase, adbc::r::ConnectionObjectBase,
+                    MonkeyDriverStatement>;
+
+static AdbcStatusCode MonkeyDriverInitFunc(int version, void* raw_driver,
+                                           AdbcError* error) {
+  return MonkeyDriver::Init(version, raw_driver, error);
+}
+
+extern "C" SEXP RAdbcMonkeyDriverInitFunc(void) {
+  SEXP xptr =
+      PROTECT(R_MakeExternalPtrFn((DL_FUNC)MonkeyDriverInitFunc, R_NilValue, R_NilValue));
+  Rf_setAttrib(xptr, R_ClassSymbol, Rf_mkString("adbc_driver_init_func"));
+  UNPROTECT(1);
+  return xptr;
+}
+
+class LogDriverDatabase : public adbc::r::DatabaseObjectBase {
+ public:
+  LogDriverDatabase() { Rprintf("LogDatabaseNew()\n"); }
+
+  ~LogDriverDatabase() { Rprintf("LogDatabaseRelease()\n"); }
+
+  AdbcStatusCode SetOption(const std::string& key, const Option& value) {

Review Comment:
   Feel free to ignore, but the method order within this class and others jumped out at me. Here, it's SetOption, Init, GetOption, elsewhere it's Init, SetOption, GetOption. Consistency has some advantages, as does some sort of natural ordering. For me that'd be Init, GetOption, SetOption, and the rest in whatever natural order makes sense.



##########
r/adbcdrivermanager/src/driver_test.cc:
##########
@@ -0,0 +1,280 @@
+// 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.
+
+#define R_NO_REMAP
+#include <R.h>
+#include <Rinternals.h>
+
+#include <cstring>
+
+#include "driver_base.h"
+
+#include <adbc.h>
+
+using adbc::r::Option;
+
+using VoidDriver =
+    adbc::r::Driver<adbc::r::DatabaseObjectBase, adbc::r::ConnectionObjectBase,
+                    adbc::r::StatementObjectBase>;
+
+static AdbcStatusCode VoidDriverInitFunc(int version, void* raw_driver,
+                                         AdbcError* error) {
+  return VoidDriver::Init(version, raw_driver, error);
+}
+
+extern "C" SEXP RAdbcVoidDriverInitFunc(void) {
+  SEXP xptr =
+      PROTECT(R_MakeExternalPtrFn((DL_FUNC)VoidDriverInitFunc, R_NilValue, R_NilValue));
+  Rf_setAttrib(xptr, R_ClassSymbol, Rf_mkString("adbc_driver_init_func"));
+  UNPROTECT(1);
+  return xptr;
+}
+
+class MonkeyDriverStatement : public adbc::r::StatementObjectBase {
+ public:
+  MonkeyDriverStatement() { stream_.release = nullptr; }
+
+  ~MonkeyDriverStatement() {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);
+    }
+  }
+
+  AdbcStatusCode BindStream(ArrowArrayStream* stream, AdbcError* error) {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);
+    }
+
+    std::memcpy(&stream_, stream, sizeof(ArrowArrayStream));
+    stream->release = nullptr;
+    return ADBC_STATUS_OK;
+  }
+
+  AdbcStatusCode ExecuteQuery(ArrowArrayStream* stream, int64_t* rows_affected,
+                              AdbcError* error) {
+    if (stream != nullptr) {
+      std::memcpy(stream, &stream_, sizeof(ArrowArrayStream));
+      stream_.release = nullptr;
+    }
+
+    *rows_affected = -1;

Review Comment:
   Still learning ADBC as I go, but the change from 0 to -1 here caused me to go look it up. I see -1 here is matching the spec so 👍 but I also noticed,
   
   > Pass NULL if the client does not want this information.
   
   Is that relevant here and, if so, should it be handled here and lots of other places? I see the C SQLite driver guards it with a null-check,
   
   ```c
     if (rows_affected) *rows_affected = row_count;
   ```
   
   https://github.com/apache/arrow-adbc/blob/a9c4f55da8d227f160705b7f9a31838fc555ab20/c/driver/sqlite/sqlite.c/#L1412



##########
r/adbcdrivermanager/src/driver_test.cc:
##########
@@ -0,0 +1,280 @@
+// 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.
+
+#define R_NO_REMAP
+#include <R.h>
+#include <Rinternals.h>
+
+#include <cstring>
+
+#include "driver_base.h"
+
+#include <adbc.h>
+
+using adbc::r::Option;
+
+using VoidDriver =
+    adbc::r::Driver<adbc::r::DatabaseObjectBase, adbc::r::ConnectionObjectBase,
+                    adbc::r::StatementObjectBase>;
+
+static AdbcStatusCode VoidDriverInitFunc(int version, void* raw_driver,
+                                         AdbcError* error) {
+  return VoidDriver::Init(version, raw_driver, error);
+}
+
+extern "C" SEXP RAdbcVoidDriverInitFunc(void) {
+  SEXP xptr =
+      PROTECT(R_MakeExternalPtrFn((DL_FUNC)VoidDriverInitFunc, R_NilValue, R_NilValue));
+  Rf_setAttrib(xptr, R_ClassSymbol, Rf_mkString("adbc_driver_init_func"));
+  UNPROTECT(1);
+  return xptr;
+}
+
+class MonkeyDriverStatement : public adbc::r::StatementObjectBase {
+ public:
+  MonkeyDriverStatement() { stream_.release = nullptr; }
+
+  ~MonkeyDriverStatement() {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);
+    }
+  }
+
+  AdbcStatusCode BindStream(ArrowArrayStream* stream, AdbcError* error) {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);
+    }
+
+    std::memcpy(&stream_, stream, sizeof(ArrowArrayStream));
+    stream->release = nullptr;
+    return ADBC_STATUS_OK;
+  }
+
+  AdbcStatusCode ExecuteQuery(ArrowArrayStream* stream, int64_t* rows_affected,
+                              AdbcError* error) {
+    if (stream != nullptr) {
+      std::memcpy(stream, &stream_, sizeof(ArrowArrayStream));
+      stream_.release = nullptr;
+    }
+
+    *rows_affected = -1;

Review Comment:
   Still learning ADBC as I go, but the change from 0 to -1 here caused me to go look it up. I see -1 here is matching the spec so 👍 but I also noticed,
   
   > Pass NULL if the client does not want this information.
   
   Is that relevant here and, if so, should it be handled here and lots of other places? I see the C SQLite driver guards it with a null-check,
   
   ```c
     if (rows_affected) *rows_affected = row_count;
   ```
   
   https://github.com/apache/arrow-adbc/blob/a9c4f55da8d227f160705b7f9a31838fc555ab20/c/driver/sqlite/sqlite.c/#L1412



##########
r/adbcdrivermanager/src/driver_test.cc:
##########
@@ -0,0 +1,280 @@
+// 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.
+
+#define R_NO_REMAP
+#include <R.h>
+#include <Rinternals.h>
+
+#include <cstring>
+
+#include "driver_base.h"
+
+#include <adbc.h>
+
+using adbc::r::Option;
+
+using VoidDriver =
+    adbc::r::Driver<adbc::r::DatabaseObjectBase, adbc::r::ConnectionObjectBase,
+                    adbc::r::StatementObjectBase>;
+
+static AdbcStatusCode VoidDriverInitFunc(int version, void* raw_driver,
+                                         AdbcError* error) {
+  return VoidDriver::Init(version, raw_driver, error);
+}
+
+extern "C" SEXP RAdbcVoidDriverInitFunc(void) {
+  SEXP xptr =
+      PROTECT(R_MakeExternalPtrFn((DL_FUNC)VoidDriverInitFunc, R_NilValue, R_NilValue));
+  Rf_setAttrib(xptr, R_ClassSymbol, Rf_mkString("adbc_driver_init_func"));
+  UNPROTECT(1);
+  return xptr;
+}
+
+class MonkeyDriverStatement : public adbc::r::StatementObjectBase {
+ public:
+  MonkeyDriverStatement() { stream_.release = nullptr; }
+
+  ~MonkeyDriverStatement() {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);

Review Comment:
   Also still learning here, but does this destructor also need to set `stream_.release` to NULL after calling it?



-- 
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] refactor(r/adbcdrivermanager): Use C++ base driver to implement test drivers [arrow-adbc]

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


##########
r/adbcdrivermanager/src/driver_test.cc:
##########
@@ -0,0 +1,280 @@
+// 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.
+
+#define R_NO_REMAP
+#include <R.h>
+#include <Rinternals.h>
+
+#include <cstring>
+
+#include "driver_base.h"
+
+#include <adbc.h>
+
+using adbc::r::Option;
+
+using VoidDriver =
+    adbc::r::Driver<adbc::r::DatabaseObjectBase, adbc::r::ConnectionObjectBase,
+                    adbc::r::StatementObjectBase>;
+
+static AdbcStatusCode VoidDriverInitFunc(int version, void* raw_driver,
+                                         AdbcError* error) {
+  return VoidDriver::Init(version, raw_driver, error);
+}
+
+extern "C" SEXP RAdbcVoidDriverInitFunc(void) {
+  SEXP xptr =
+      PROTECT(R_MakeExternalPtrFn((DL_FUNC)VoidDriverInitFunc, R_NilValue, R_NilValue));
+  Rf_setAttrib(xptr, R_ClassSymbol, Rf_mkString("adbc_driver_init_func"));
+  UNPROTECT(1);
+  return xptr;
+}
+
+class MonkeyDriverStatement : public adbc::r::StatementObjectBase {
+ public:
+  MonkeyDriverStatement() { stream_.release = nullptr; }
+
+  ~MonkeyDriverStatement() {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);

Review Comment:
   Technically the release callback itself is responsible for that...there are definitely some places (e.g., Arrow C++) that use an `assert()` here to make sure that it happened. In R packages `assert()` isn't allowed, which is why I don't do it here.



-- 
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] refactor(r/adbcdrivermanager): Use C++ base driver to implement test drivers [arrow-adbc]

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


##########
r/adbcdrivermanager/src/driver_test.cc:
##########
@@ -0,0 +1,280 @@
+// 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.
+
+#define R_NO_REMAP
+#include <R.h>
+#include <Rinternals.h>
+
+#include <cstring>
+
+#include "driver_base.h"
+
+#include <adbc.h>
+
+using adbc::r::Option;
+
+using VoidDriver =
+    adbc::r::Driver<adbc::r::DatabaseObjectBase, adbc::r::ConnectionObjectBase,
+                    adbc::r::StatementObjectBase>;
+
+static AdbcStatusCode VoidDriverInitFunc(int version, void* raw_driver,
+                                         AdbcError* error) {
+  return VoidDriver::Init(version, raw_driver, error);
+}
+
+extern "C" SEXP RAdbcVoidDriverInitFunc(void) {
+  SEXP xptr =
+      PROTECT(R_MakeExternalPtrFn((DL_FUNC)VoidDriverInitFunc, R_NilValue, R_NilValue));
+  Rf_setAttrib(xptr, R_ClassSymbol, Rf_mkString("adbc_driver_init_func"));
+  UNPROTECT(1);
+  return xptr;
+}
+
+class MonkeyDriverStatement : public adbc::r::StatementObjectBase {
+ public:
+  MonkeyDriverStatement() { stream_.release = nullptr; }
+
+  ~MonkeyDriverStatement() {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);
+    }
+  }
+
+  AdbcStatusCode BindStream(ArrowArrayStream* stream, AdbcError* error) {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);
+    }
+
+    std::memcpy(&stream_, stream, sizeof(ArrowArrayStream));
+    stream->release = nullptr;
+    return ADBC_STATUS_OK;
+  }
+
+  AdbcStatusCode ExecuteQuery(ArrowArrayStream* stream, int64_t* rows_affected,
+                              AdbcError* error) {
+    if (stream != nullptr) {
+      std::memcpy(stream, &stream_, sizeof(ArrowArrayStream));
+      stream_.release = nullptr;
+    }
+
+    *rows_affected = -1;

Review Comment:
   Good catch!



-- 
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] refactor(r/adbcdrivermanager): Use C++ base driver to implement test drivers [arrow-adbc]

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


-- 
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] refactor(r/adbcdrivermanager): Use C++ base driver to implement test drivers [arrow-adbc]

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

   @amoeba Do you mind taking a look at this when you have a moment?


-- 
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] refactor(r/adbcdrivermanager): Use C++ base driver to implement test drivers [arrow-adbc]

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


##########
r/adbcdrivermanager/src/driver_test.cc:
##########
@@ -0,0 +1,280 @@
+// 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.
+
+#define R_NO_REMAP
+#include <R.h>
+#include <Rinternals.h>
+
+#include <cstring>
+
+#include "driver_base.h"
+
+#include <adbc.h>
+
+using adbc::r::Option;
+
+using VoidDriver =
+    adbc::r::Driver<adbc::r::DatabaseObjectBase, adbc::r::ConnectionObjectBase,
+                    adbc::r::StatementObjectBase>;
+
+static AdbcStatusCode VoidDriverInitFunc(int version, void* raw_driver,
+                                         AdbcError* error) {
+  return VoidDriver::Init(version, raw_driver, error);
+}
+
+extern "C" SEXP RAdbcVoidDriverInitFunc(void) {
+  SEXP xptr =
+      PROTECT(R_MakeExternalPtrFn((DL_FUNC)VoidDriverInitFunc, R_NilValue, R_NilValue));
+  Rf_setAttrib(xptr, R_ClassSymbol, Rf_mkString("adbc_driver_init_func"));
+  UNPROTECT(1);
+  return xptr;
+}
+
+class MonkeyDriverStatement : public adbc::r::StatementObjectBase {
+ public:
+  MonkeyDriverStatement() { stream_.release = nullptr; }
+
+  ~MonkeyDriverStatement() {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);
+    }
+  }
+
+  AdbcStatusCode BindStream(ArrowArrayStream* stream, AdbcError* error) {
+    if (stream_.release != nullptr) {
+      stream_.release(&stream_);
+    }
+
+    std::memcpy(&stream_, stream, sizeof(ArrowArrayStream));
+    stream->release = nullptr;
+    return ADBC_STATUS_OK;
+  }
+
+  AdbcStatusCode ExecuteQuery(ArrowArrayStream* stream, int64_t* rows_affected,
+                              AdbcError* error) {
+    if (stream != nullptr) {
+      std::memcpy(stream, &stream_, sizeof(ArrowArrayStream));
+      stream_.release = nullptr;
+    }
+
+    *rows_affected = -1;
+    return ADBC_STATUS_OK;
+  }
+
+ private:
+  ArrowArrayStream stream_;
+};
+
+using MonkeyDriver =
+    adbc::r::Driver<adbc::r::DatabaseObjectBase, adbc::r::ConnectionObjectBase,
+                    MonkeyDriverStatement>;
+
+static AdbcStatusCode MonkeyDriverInitFunc(int version, void* raw_driver,
+                                           AdbcError* error) {
+  return MonkeyDriver::Init(version, raw_driver, error);
+}
+
+extern "C" SEXP RAdbcMonkeyDriverInitFunc(void) {
+  SEXP xptr =
+      PROTECT(R_MakeExternalPtrFn((DL_FUNC)MonkeyDriverInitFunc, R_NilValue, R_NilValue));
+  Rf_setAttrib(xptr, R_ClassSymbol, Rf_mkString("adbc_driver_init_func"));
+  UNPROTECT(1);
+  return xptr;
+}
+
+class LogDriverDatabase : public adbc::r::DatabaseObjectBase {
+ public:
+  LogDriverDatabase() { Rprintf("LogDatabaseNew()\n"); }
+
+  ~LogDriverDatabase() { Rprintf("LogDatabaseRelease()\n"); }
+
+  AdbcStatusCode SetOption(const std::string& key, const Option& value) {

Review Comment:
   Good catch!



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