Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Loading