diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml
index 3de38eea84..22efb9b451 100644
--- a/.github/workflows/packaging.yml
+++ b/.github/workflows/packaging.yml
@@ -120,11 +120,62 @@ jobs:
path: |
apache-arrow-adbc-${{ steps.version.outputs.VERSION }}.tar.gz
+ go-binaries:
+ name: "Go ${{ matrix.os }}"
+ runs-on: ${{ matrix.os }}
+ needs:
+ - source
+
+ strategy:
+ matrix:
+ os: ["ubuntu-latest", "windows-latest", "macos-13"]
+ go-version: [1.21.8] # Customize Go versions as needed
+
+ steps:
+ - uses: actions/download-artifact@v4
+ with:
+ name: source
+
+ - name: Extract source archive
+ run: |
+ source_archive=$(echo apache-arrow-adbc-*.tar.gz)
+ VERSION=${source_archive#apache-arrow-adbc-}
+ VERSION=${VERSION%.tar.gz}
+ echo "VERSION=${VERSION}" >> $GITHUB_ENV
+
+ tar xf apache-arrow-adbc-${VERSION}.tar.gz
+ mv apache-arrow-adbc-${VERSION} adbc
+
+ - name: Setup Go
+ uses: actions/setup-go@v5
+ with:
+ go-version: ${{ matrix.go-version }}
+ check-latest: true
+ cache: true
+ cache-dependency-path: adbc/go/adbc/go.sum
+
+ # run `make -i` because the Windows runs claim they can't delete the .h files, but they are still generated
+ - name: Build Go binaries
+ run: |
+ pushd adbc/go/adbc/pkg
+ make -i
+ popd
+
+ - name: Upload Go binaries
+ uses: actions/upload-artifact@v3
+ with:
+ retention-days: 7
+ path: |
+ adbc/go/adbc/pkg/libadbc_driver_flightsql.*
+ adbc/go/adbc/pkg/libadbc_driver_snowflake.*
+
csharp:
name: "C#/.NET"
runs-on: ubuntu-latest
needs:
- source
+ - go-binaries
+
steps:
- uses: actions/download-artifact@v4
with:
@@ -146,10 +197,22 @@ jobs:
echo "schedule: ${{ github.event.schedule }}" >> $GITHUB_STEP_SUMMARY
echo "ref: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY
+ - uses: actions/download-artifact@v3
+ with:
+ path: adbc/go/adbc/pkg
+
+ - name: Copy Go binaries
+ run: |
+ pushd adbc/go/adbc/pkg/artifact
+ cp *.dll ../
+ cp *.so ../
+ cp *.dylib ../
+ popd
+
- name: Package
run: |
pushd adbc/
- docker compose run csharp-dist
+ docker compose run -e IsPackagingPipeline=true csharp-dist
popd
- name: Archive nupkg
diff --git a/csharp/src/Drivers/Interop/Snowflake/Apache.Arrow.Adbc.Drivers.Interop.Snowflake.csproj b/csharp/src/Drivers/Interop/Snowflake/Apache.Arrow.Adbc.Drivers.Interop.Snowflake.csproj
index 815418f5a3..cb810a99be 100644
--- a/csharp/src/Drivers/Interop/Snowflake/Apache.Arrow.Adbc.Drivers.Interop.Snowflake.csproj
+++ b/csharp/src/Drivers/Interop/Snowflake/Apache.Arrow.Adbc.Drivers.Interop.Snowflake.csproj
@@ -2,37 +2,64 @@
netstandard2.0;net472;net6.0
readme.md
+
+ false
+
+
-
+
-
+
+
+
+
+
-
+
true
- lib\netstandard2.0
+ /
PreserveNewest
-
+
true
- lib\net472
+ runtimes/win-x64/native
PreserveNewest
-
+
+
+
+
+
true
- lib\net6.0
+ /
PreserveNewest
-
-
-
+
+
+
+ true
+ runtimes/win-x64/native
+ PreserveNewest
+
+
+
+
true
- \
+ runtimes/linux-x64/native
+ PreserveNewest
+
+
+
+
+ true
+ runtimes/osx-x64/native
PreserveNewest
+
diff --git a/csharp/src/Drivers/Interop/Snowflake/Build-SnowflakeDriver.ps1 b/csharp/src/Drivers/Interop/Snowflake/Build-SnowflakeDriver.ps1
index cbb69e343a..5a4dbb3876 100644
--- a/csharp/src/Drivers/Interop/Snowflake/Build-SnowflakeDriver.ps1
+++ b/csharp/src/Drivers/Interop/Snowflake/Build-SnowflakeDriver.ps1
@@ -15,22 +15,49 @@
# limitations under the License.
Write-Host "Building the Snowflake 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_snowflake.dll"
+if(Test-Path $file)
+{
+ exit
+}
+
cd ..\..\..\..\..\go\adbc\pkg
+make $file
+
if(Test-Path $file)
{
- #because each framework build will run the script, avoid building it each time
- $diff=((ls $file).LastWriteTime - (Get-Date)).TotalSeconds
- if ($diff -gt -30)
- {
- Write-Output "Skipping build of $file because it is too recent"
- exit
+ $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."
}
}
-make $file
-COPY $file $location
diff --git a/csharp/src/Drivers/Interop/Snowflake/SnowflakeDriverLoader.cs b/csharp/src/Drivers/Interop/Snowflake/SnowflakeDriverLoader.cs
index 2719ac5943..5229f64582 100644
--- a/csharp/src/Drivers/Interop/Snowflake/SnowflakeDriverLoader.cs
+++ b/csharp/src/Drivers/Interop/Snowflake/SnowflakeDriverLoader.cs
@@ -16,6 +16,7 @@
*/
using System.IO;
+using System.Runtime.InteropServices;
using Apache.Arrow.Adbc.C;
namespace Apache.Arrow.Adbc.Drivers.Interop.Snowflake
@@ -32,7 +33,18 @@ public class SnowflakeDriverLoader
///
public static AdbcDriver LoadDriver()
{
- string file = "libadbc_driver_snowflake.dll";
+ string root = "runtimes";
+ string native = "native";
+ string fileName = $"libadbc_driver_snowflake";
+ 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))
{
@@ -47,6 +59,11 @@ public static AdbcDriver LoadDriver()
return LoadDriver(file, "SnowflakeDriverInit");
}
+ private static string GetArchitecture()
+ {
+ return RuntimeInformation.OSArchitecture.ToString().ToLower();
+ }
+
///
/// Loads the Snowflake Go driver from the current directory using the default name and entry point.
///
diff --git a/csharp/src/Drivers/Interop/Snowflake/copySnowflakeDriver.sh b/csharp/src/Drivers/Interop/Snowflake/copySnowflakeDriver.sh
new file mode 100644
index 0000000000..69e409a704
--- /dev/null
+++ b/csharp/src/Drivers/Interop/Snowflake/copySnowflakeDriver.sh
@@ -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"
+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_snowflake.*"
+
+if ls libadbc_driver_snowflake.* 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