From 0d42b93675adf14ad1dbc4489f7088d9577226cb Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Wed, 28 Oct 2026 15:43:14 -0700 Subject: [PATCH 1/2] Add failing test --- .../CAdbcDriverImporterFallbackTests.cs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 csharp/test/Apache.Arrow.Adbc.Tests/CAdbcDriverImporterFallbackTests.cs diff --git a/csharp/test/Apache.Arrow.Adbc.Tests/CAdbcDriverImporterFallbackTests.cs b/csharp/test/Apache.Arrow.Adbc.Tests/CAdbcDriverImporterFallbackTests.cs new file mode 100644 index 0000000000..aeb8c8686c --- /dev/null +++ b/csharp/test/Apache.Arrow.Adbc.Tests/CAdbcDriverImporterFallbackTests.cs @@ -0,0 +1,44 @@ +/* + * 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. + */ + +using System.IO; +using System.Runtime.InteropServices; +using Apache.Arrow.Adbc.C; +using Xunit; + +namespace Apache.Arrow.Adbc.Tests +{ + public class CAdbcDriverImporterFallbackTests + { + // When the library doesn't export the requested entrypoint, the fallback + // entrypoint should be used. DuckDB only exports duckdb_adbc_init. + [Fact] + public void LoadWithFallback_MissingEntrypoint_UsesFallback() + { + string duckDb = Path.Combine( + Directory.GetCurrentDirectory(), + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "duckdb.dll" + : RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "libduckdb.dylib" + : "libduckdb.so"); + + using AdbcDriver driver = CAdbcDriverImporter.LoadWithFallback( + duckDb, "AdbcTestNoSuchEntrypoint", "duckdb_adbc_init"); + + Assert.NotNull(driver); + } + } +} From b7d22a092c9b13d2514972c8b095ce63a92562e5 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Wed, 28 Oct 2026 15:55:57 -0700 Subject: [PATCH 2/2] Add fix --- csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs b/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs index 19b85e123a..4326253f5d 100644 --- a/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs +++ b/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs @@ -91,6 +91,12 @@ private static AdbcDriver Load( export = NativeLibrary.GetExport(library, entryPoint); } catch (EntryPointNotFoundException) when (fallbackEntryPoint != null) + { + export = IntPtr.Zero; + } + // The runtime's NativeLibrary.GetExport throws for a missing export, + // but the netstandard2.0 NativeLibrary shim returns IntPtr.Zero + if (export == IntPtr.Zero && fallbackEntryPoint != null) { export = NativeLibrary.GetExport(library, fallbackEntryPoint); }