Skip to content

Commit 16269af

Browse files
authored
fix(c/driver_manager): use Driver.entrypoint as per docs (apache#3242)
As per the [docs](https://arrow.apache.org/adbc/main/format/driver_manifests.html#manifest-structure) the Driver manifest allows overriding the `entrypoint` via the `Driver.entrypoint` key. Rust follows this properly, but C++ checks for a top-level key named `entrypoint` instead of following the docs. This PR fixes this so that the C++ driver manager correctly looks for `Driver.entrypoint`.
1 parent 0489d94 commit 16269af

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

c/driver_manager/adbc_driver_manager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ AdbcStatusCode LoadDriverManifest(const std::filesystem::path& driver_manifest,
253253

254254
info.manifest_file = driver_manifest.string();
255255
info.driver_name = config["name"].value_or(""s);
256-
info.entrypoint = config["entrypoint"].value_or(""s);
256+
info.entrypoint = config.at_path("Driver.entrypoint").value_or(""s);
257257
info.version = config["version"].value_or(""s);
258258
info.source = config["source"].value_or(""s);
259259

c/driver_manager/adbc_driver_manager_test.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,32 @@ TEST_F(DriverManifest, DisallowEnvConfig) {
526526
UnsetConfigPath();
527527
}
528528

529+
TEST_F(DriverManifest, ConfigEntrypoint) {
530+
auto manifest_with_bad_entrypoint = simple_manifest;
531+
// Override the entrypoint in the manifest
532+
manifest_with_bad_entrypoint.erase("Driver");
533+
manifest_with_bad_entrypoint.insert(
534+
"Driver", toml::table{
535+
{"entrypoint", "BadEntrypointSymbolName"},
536+
{"shared",
537+
toml::table{
538+
{adbc::CurrentArch(), driver_path.string()},
539+
}},
540+
});
541+
542+
auto filepath = temp_dir / "sqlite.toml";
543+
std::ofstream test_manifest_file(filepath);
544+
ASSERT_TRUE(test_manifest_file.is_open());
545+
test_manifest_file << manifest_with_bad_entrypoint;
546+
test_manifest_file.close();
547+
548+
ASSERT_THAT(AdbcFindLoadDriver(filepath.string().data(), nullptr, ADBC_VERSION_1_1_0,
549+
ADBC_LOAD_FLAG_DEFAULT, &driver, &error),
550+
Not(IsOkStatus(&error)));
551+
552+
ASSERT_TRUE(std::filesystem::remove(filepath));
553+
}
554+
529555
TEST_F(DriverManifest, LoadAbsolutePath) {
530556
auto filepath = temp_dir / "sqlite.toml";
531557
std::ofstream test_manifest_file(filepath);

go/adbc/drivermgr/adbc_driver_manager.cc

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

r/adbcdrivermanager/tests/testthat/test-driver_void.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ test_that("drivers are loaded using load_flags", {
6262
test_that("drivers can be loaded by manifest path", {
6363
toml_content <- sprintf("
6464
name = 'Void Driver'
65-
entrypoint = 'AdbcTestVoidDriverInit'
6665
6766
[ADBC]
6867
version = 'v1.1.0'
6968
7069
[Driver]
70+
entrypoint = 'AdbcTestVoidDriverInit'
71+
7172
[Driver.shared]
7273
%s = '%s'
7374

0 commit comments

Comments
 (0)