Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(csharp/src/Drivers): introduce Interop.FlightSql driver #2214

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4655e76
introduce FlightSql interop
Feb 5, 2024
91d44f6
more updates
Feb 8, 2024
f3d9c3c
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
Feb 8, 2024
5c35df5
ExecuteResults working
Feb 21, 2024
a69c345
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
Feb 21, 2024
57f8ef2
latest flight
Feb 22, 2024
257b70a
Merging from main repo
vleslief-ms Apr 10, 2024
c491911
test(csharp/test/Drivers/Interop/FlightSql): Getting tests working be…
vleslief-ms Apr 10, 2024
9eaa016
update to latest; clean up nulls
Sep 3, 2024
4027d2a
getting on par with Snowflake interop
Sep 4, 2024
54730c7
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
Sep 10, 2024
35d2bfe
add support for multiple flight environments; type tests
Sep 11, 2024
2fca8e4
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
Sep 24, 2024
4f633b4
add support for IntervalType
Sep 24, 2024
8f04808
working on multi environments
Sep 26, 2024
1474e1b
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
Sep 30, 2024
a2cdadf
support multiple test environments
Oct 1, 2024
1488ff0
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
Oct 1, 2024
68ef07b
support multiple environments in tests
Oct 1, 2024
f850e56
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
Oct 2, 2024
1891827
clean up after merge; multi-environment support for sample data
Oct 2, 2024
1c4e3b2
fix json element
Oct 2, 2024
fbd8e87
add support for SQLite
Oct 3, 2024
7fc08cc
Update csharp/src/Drivers/Interop/FlightSql/copyFlightSqlDriver.sh
davidhcoe Oct 15, 2024
86d415a
PR feedback
Oct 15, 2024
844c015
re-add original FlightSql C# driver; differentiate config environment…
Oct 15, 2024
333e645
merge latest
Nov 1, 2024
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
28 changes: 14 additions & 14 deletions csharp/Apache.Arrow.Adbc.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5BD04C26
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Drivers", "Drivers", "{FEB257A0-4FD3-495E-9A47-9E1649755445}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Drivers.FlightSql", "src\Drivers\FlightSql\Apache.Arrow.Adbc.Drivers.FlightSql.csproj", "{19AA450A-2F87-49BD-9122-8AD07D4C6DCE}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't seem to be deleting these projects -- and I think we probably shouldn't -- so why remove them from the solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed them so they would no longer be built with the solution and new versions of the NuGet packages wouldn't continue to generate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But don't you think that someone using .NET 8 would prefer to use these over the interop version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would just cause confusion. My intent was to show the native .NET one hasn't been updated in a while to then deprecate it, but we can keep it for now.

EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Drivers", "Drivers", "{C7290227-E925-47E7-8B6B-A8B171645D58}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Tests.Drivers.FlightSql", "test\Drivers\FlightSql\Apache.Arrow.Adbc.Tests.Drivers.FlightSql.csproj", "{5C15E79C-19C4-4FF4-BB82-28754FE3966B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Client", "Client", "{B6111602-2DC4-4B2F-9598-E3EE1972D3E4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Client", "src\Client\Apache.Arrow.Adbc.Client.csproj", "{A405F4A0-5938-4139-B2DF-ED9A05EC3D7C}"
Expand All @@ -32,6 +28,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Drivers.A
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Tests.Drivers.Apache", "test\Drivers\Apache\Apache.Arrow.Adbc.Tests.Drivers.Apache.csproj", "{714F0BD2-3A92-4D1A-8FAC-D0C0599BE3E3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Drivers.Interop.FlightSql", "src\Drivers\Interop\FlightSql\Apache.Arrow.Adbc.Drivers.Interop.FlightSql.csproj", "{4076D7E9-728D-4DF4-999F-658784957648}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Tests.Drivers.Interop.FlightSql", "test\Drivers\Interop\FlightSql\Apache.Arrow.Adbc.Tests.Drivers.Interop.FlightSql.csproj", "{C5503227-C5A7-406F-83AA-681F292EA61F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -46,14 +46,6 @@ Global
{00C143BA-F1CF-4117-9DE6-E73DC4D208F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00C143BA-F1CF-4117-9DE6-E73DC4D208F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00C143BA-F1CF-4117-9DE6-E73DC4D208F8}.Release|Any CPU.Build.0 = Release|Any CPU
{19AA450A-2F87-49BD-9122-8AD07D4C6DCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19AA450A-2F87-49BD-9122-8AD07D4C6DCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19AA450A-2F87-49BD-9122-8AD07D4C6DCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19AA450A-2F87-49BD-9122-8AD07D4C6DCE}.Release|Any CPU.Build.0 = Release|Any CPU
{5C15E79C-19C4-4FF4-BB82-28754FE3966B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C15E79C-19C4-4FF4-BB82-28754FE3966B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C15E79C-19C4-4FF4-BB82-28754FE3966B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C15E79C-19C4-4FF4-BB82-28754FE3966B}.Release|Any CPU.Build.0 = Release|Any CPU
{A405F4A0-5938-4139-B2DF-ED9A05EC3D7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A405F4A0-5938-4139-B2DF-ED9A05EC3D7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A405F4A0-5938-4139-B2DF-ED9A05EC3D7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -82,22 +74,30 @@ Global
{714F0BD2-3A92-4D1A-8FAC-D0C0599BE3E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{714F0BD2-3A92-4D1A-8FAC-D0C0599BE3E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{714F0BD2-3A92-4D1A-8FAC-D0C0599BE3E3}.Release|Any CPU.Build.0 = Release|Any CPU
{4076D7E9-728D-4DF4-999F-658784957648}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4076D7E9-728D-4DF4-999F-658784957648}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4076D7E9-728D-4DF4-999F-658784957648}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4076D7E9-728D-4DF4-999F-658784957648}.Release|Any CPU.Build.0 = Release|Any CPU
{C5503227-C5A7-406F-83AA-681F292EA61F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5503227-C5A7-406F-83AA-681F292EA61F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5503227-C5A7-406F-83AA-681F292EA61F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5503227-C5A7-406F-83AA-681F292EA61F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{00C143BA-F1CF-4117-9DE6-E73DC4D208F8} = {5BD04C26-CE52-4893-8C1A-479705195CEF}
{19AA450A-2F87-49BD-9122-8AD07D4C6DCE} = {FEB257A0-4FD3-495E-9A47-9E1649755445}
{C7290227-E925-47E7-8B6B-A8B171645D58} = {5BD04C26-CE52-4893-8C1A-479705195CEF}
{5C15E79C-19C4-4FF4-BB82-28754FE3966B} = {C7290227-E925-47E7-8B6B-A8B171645D58}
{A405F4A0-5938-4139-B2DF-ED9A05EC3D7C} = {B6111602-2DC4-4B2F-9598-E3EE1972D3E4}
{A748041C-EF9A-4E88-B6FB-9F2D6CB79170} = {FEB257A0-4FD3-495E-9A47-9E1649755445}
{EA43BB7C-BC00-4701-BDF4-367880C2495C} = {C7290227-E925-47E7-8B6B-A8B171645D58}
{30024B6F-7BC1-4574-BE5A-924FBD6EAF83} = {FEB257A0-4FD3-495E-9A47-9E1649755445}
{8BE1EECC-3ACF-41B2-AF7D-1A67196FF6C7} = {C7290227-E925-47E7-8B6B-A8B171645D58}
{6C0D8BE1-4A23-4C2F-88B1-D2FBEA0B1903} = {FEB257A0-4FD3-495E-9A47-9E1649755445}
{714F0BD2-3A92-4D1A-8FAC-D0C0599BE3E3} = {C7290227-E925-47E7-8B6B-A8B171645D58}
{4076D7E9-728D-4DF4-999F-658784957648} = {FEB257A0-4FD3-495E-9A47-9E1649755445}
{C5503227-C5A7-406F-83AA-681F292EA61F} = {C7290227-E925-47E7-8B6B-A8B171645D58}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4795CF16-0FDB-4BE0-9768-5CF31564DC03}
Expand Down
8 changes: 7 additions & 1 deletion csharp/src/Apache.Arrow.Adbc/AdbcStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ public virtual void Dispose()
return uInt32Array.GetValue(index);
case UInt64Array uInt64Array:
return uInt64Array.GetValue(index);

case DayTimeIntervalArray dayTimeIntervalArray:
return dayTimeIntervalArray.GetValue(index);
case MonthDayNanosecondIntervalArray monthDayNanosecondIntervalArray:
return monthDayNanosecondIntervalArray.GetValue(index);
case YearMonthIntervalArray yearMonthIntervalArray:
return yearMonthIntervalArray.GetValue(index);
case BinaryArray binaryArray:
if (!binaryArray.IsNull(index))
return binaryArray.GetBytes(index).ToArray();
Expand All @@ -250,6 +255,7 @@ public virtual void Dispose()

// not covered:
// -- struct array
// -- map array
// -- dictionary array
// -- fixed size binary
// -- list array
Expand Down
1 change: 1 addition & 0 deletions csharp/src/Apache.Arrow.Adbc/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@

[assembly: InternalsVisibleTo("Apache.Arrow.Adbc.Drivers.Apache, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e504183f6d470d6b67b6d19212be3e1f598f70c246a120194bc38130101d0c1853e4a0f2232cb12e37a7a90e707aabd38511dac4f25fcb0d691b2aa265900bf42de7f70468fc997551a40e1e0679b605aa2088a4a69e07c117e988f5b1738c570ee66997fba02485e7856a49eca5fd0706d09899b8312577cbb9034599fc92d4")]
[assembly: InternalsVisibleTo("Apache.Arrow.Adbc.Drivers.BigQuery, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e504183f6d470d6b67b6d19212be3e1f598f70c246a120194bc38130101d0c1853e4a0f2232cb12e37a7a90e707aabd38511dac4f25fcb0d691b2aa265900bf42de7f70468fc997551a40e1e0679b605aa2088a4a69e07c117e988f5b1738c570ee66997fba02485e7856a49eca5fd0706d09899b8312577cbb9034599fc92d4")]
[assembly: InternalsVisibleTo("Apache.Arrow.Adbc.Tests.Drivers.Interop.FlightSql, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e504183f6d470d6b67b6d19212be3e1f598f70c246a120194bc38130101d0c1853e4a0f2232cb12e37a7a90e707aabd38511dac4f25fcb0d691b2aa265900bf42de7f70468fc997551a40e1e0679b605aa2088a4a69e07c117e988f5b1738c570ee66997fba02485e7856a49eca5fd0706d09899b8312577cbb9034599fc92d4")]
[assembly: InternalsVisibleTo("Apache.Arrow.Adbc.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e504183f6d470d6b67b6d19212be3e1f598f70c246a120194bc38130101d0c1853e4a0f2232cb12e37a7a90e707aabd38511dac4f25fcb0d691b2aa265900bf42de7f70468fc997551a40e1e0679b605aa2088a4a69e07c117e988f5b1738c570ee66997fba02485e7856a49eca5fd0706d09899b8312577cbb9034599fc92d4")]
12 changes: 12 additions & 0 deletions csharp/src/Client/SchemaConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Data;
using System.Data.Common;
using System.Data.SqlTypes;
using Apache.Arrow.Scalars;
using Apache.Arrow.Types;

namespace Apache.Arrow.Adbc.Client
Expand Down Expand Up @@ -190,6 +191,17 @@ public static Type GetArrowType(Field f, DecimalBehavior decimalBehavior)
case ArrowTypeId.Null:
return typeof(DBNull);

case ArrowTypeId.Interval:
switch (((IntervalType)f.DataType).Unit) {
case IntervalUnit.MonthDayNanosecond:
return typeof(MonthDayNanosecondInterval);
case IntervalUnit.DayTime:
return typeof(DayTimeInterval);
case IntervalUnit.YearMonth:
return typeof(YearMonthInterval);
}
goto default;

default:
return f.DataType.GetType();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472;net6.0</TargetFrameworks>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<IsPackagingPipeline Condition="'$(IsPackagingPipeline)' == ''">
false
</IsPackagingPipeline>
</PropertyGroup>

<!-- use Build-FlightSqlDriver.ps1 to build the dll -->
<Target Name="PreBuild_Win" BeforeTargets="DispatchToInnerBuilds" Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<Exec Command="powershell -ExecutionPolicy Unrestricted -File $(ProjectDir)Build-FlightSqlDriver.ps1" />
</Target>

<!-- use copyFlightSqlDriver.sh to move all the platform binaries when used in the pipeline -->
<Target Name="PreBuild_Linux" BeforeTargets="DispatchToInnerBuilds" Condition="$([MSBuild]::IsOSPlatform('Linux'))">
<Exec Command="bash $(ProjectDir)copyFlightSqlDriver.sh" />
</Target>

<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<Content Include="readme.md">
<Pack>true</Pack>
<PackagePath>/</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libadbc_driver_flightsql.dll" Condition="'$(IsPackagingPipeline)' == 'true'">
<Pack>true</Pack>
<PackagePath>runtimes/win-x64/native</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<!-- What runs in the pipeline. Assumes the Go builds have happened. -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
<Content Include="readme.md">
<Pack>true</Pack>
<PackagePath>/</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

<!-- Windows/DLLs -->
<Content Include="libadbc_driver_flightsql.dll" Condition="'$(IsPackagingPipeline)' == 'true'">
<Pack>true</Pack>
<PackagePath>runtimes/win-x64/native</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

<!-- Linux/so -->
<Content Include="libadbc_driver_flightsql.so" Condition="'$(IsPackagingPipeline)' == 'true'">
<Pack>true</Pack>
<PackagePath>runtimes/linux-x64/native</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

<!-- Mac/dylib -->
<Content Include="libadbc_driver_flightsql.dylib" Condition="'$(IsPackagingPipeline)' == 'true'">
<Pack>true</Pack>
<PackagePath>runtimes/osx-x64/native</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Apache.Arrow.Adbc\Apache.Arrow.Adbc.csproj" />
</ItemGroup>
</Project>
63 changes: 63 additions & 0 deletions csharp/src/Drivers/Interop/FlightSql/Build-FlightSqlDriver.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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.

Write-Host "Building the Flight SQL ADBC Go driver"
Write-Host "IsPackagingPipeline=$Env:IsPackagingPipeline"

if (-not (Test-Path env:IsPackagingPipeline)) {
Write-Host "IsPackagingPipeline environment variable does not exist."
exit
}

# Get the value of the IsPackagingPipeline environment variable
$IsPackagingPipelineValue = $env:IsPackagingPipeline

# Check if the value is "true"
if ($IsPackagingPipelineValue -ne "true") {
Write-Host "IsPackagingPipeline is not set to 'true'. Exiting the script."
exit
}

$location = Get-Location

$file = "libadbc_driver_flightsql.dll"

if(Test-Path $file)
{
exit
}

cd ..\..\..\..\..\go\adbc\pkg

make $file

if(Test-Path $file)
{
$processes = Get-Process | Where-Object { $_.Modules.ModuleName -contains $file }

if ($processes.Count -eq 0) {
try {
# File is not being used, copy it to the destination
Copy-Item -Path $file -Destination $location
Write-Host "File copied successfully."
}
catch {
Write-Host "Caught error: $_"
}
} else {
Write-Host "File is being used by another process. Cannot copy."
}
}
80 changes: 80 additions & 0 deletions csharp/src/Drivers/Interop/FlightSql/FlightSqlDriverLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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;

namespace Apache.Arrow.Adbc.Drivers.Interop.FlightSql
{
/// <summary>
/// Lightweight class for loading the Flight SQL Go driver to .NET.
/// </summary>
public class FlightSqlDriverLoader
{
/// <summary>
/// Loads the Flight SQL Go driver from the current directory using the default name and entry point.
/// </summary>
/// <returns>An <see cref="AdbcDriver"/> based on the Flight SQL Go driver.</returns>
/// <exception cref="FileNotFoundException"></exception>
public static AdbcDriver LoadDriver()
{
string root = "runtimes";
string native = "native";
string fileName = $"libadbc_driver_flightsql";
string file;

// matches extensions in https://github.com/apache/arrow-adbc/blob/main/go/adbc/pkg/Makefile
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
file = Path.Combine(root, $"linux-{GetArchitecture()}", native, $"{fileName}.so");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
file = Path.Combine(root, $"win-{GetArchitecture()}", native, $"{fileName}.dll");
else
file = Path.Combine(root, $"osx-{GetArchitecture()}", native, $"{fileName}.dylib");

if (File.Exists(file))
{
// get the full path because some .NET versions need it
file = Path.GetFullPath(file);
}
else
{
throw new FileNotFoundException($"Cound not find {file}");
}

return LoadDriver(file, "FlightSqlDriverInit");
}

private static string GetArchitecture()
{
return RuntimeInformation.OSArchitecture.ToString().ToLower();
}

/// <summary>
/// Loads the Flight SQL Go driver from the current directory using the default name and entry point.
/// </summary>
/// <param name="file">The file to load.</param>
/// <param name="entryPoint">The entry point of the file.</param>
/// <returns>An <see cref="AdbcDriver"/> based on the FlightSql Go driver.</returns>
public static AdbcDriver LoadDriver(string file, string entryPoint)
{
AdbcDriver flightSqlDriver = CAdbcDriverImporter.Load(file, entryPoint);

return flightSqlDriver;
}
}
}
54 changes: 54 additions & 0 deletions csharp/src/Drivers/Interop/FlightSql/copyFlightSqlDriver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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.

### copies the Snowflake binaries for all platforms to be packaged for NuGet

echo "Copying the Snowflake ADBC Go drivers"
davidhcoe marked this conversation as resolved.
Show resolved Hide resolved
echo "IsPackagingPipeline=$IsPackagingPipeline"

if [[ -z "${IsPackagingPipeline}" ]]; then
echo "IsPackagingPipeline environment variable does not exist."
exit 0
fi

# Get the value of the IsPackagingPipeline environment variable
IsPackagingPipelineValue="${IsPackagingPipeline}"

# Check if the value is "true"
if [[ "${IsPackagingPipelineValue}" != "true" ]]; then
echo "IsPackagingPipeline is not set to 'true'. Exiting the script."
exit 0
fi

destination_dir=$(pwd)

file="libadbc_driver_flightsql.*"

if ls libadbc_driver_flightsql.* 1> /dev/null 2>&1; then
echo "Files found. Exiting the script."
exit 0
else
cd ../../../../../go/adbc/pkg

source_dir=$(pwd)

files_to_copy=$(find "$source_dir" -type f -name "$file")

for file in $files_to_copy; do
cp "$file" "$destination_dir"
echo "Copied $file to $destination_dir"
done
fi
Loading
Loading