-
Notifications
You must be signed in to change notification settings - Fork 95
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
davidhcoe
wants to merge
27
commits into
apache:main
Choose a base branch
from
davidhcoe:dev/go-flight-sql-interop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
4655e76
introduce FlightSql interop
91d44f6
more updates
f3d9c3c
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
5c35df5
ExecuteResults working
a69c345
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
57f8ef2
latest flight
257b70a
Merging from main repo
vleslief-ms c491911
test(csharp/test/Drivers/Interop/FlightSql): Getting tests working be…
vleslief-ms 9eaa016
update to latest; clean up nulls
4027d2a
getting on par with Snowflake interop
54730c7
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
35d2bfe
add support for multiple flight environments; type tests
2fca8e4
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
4f633b4
add support for IntervalType
8f04808
working on multi environments
1474e1b
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
a2cdadf
support multiple test environments
1488ff0
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
68ef07b
support multiple environments in tests
f850e56
Merge ssh://github.com/davidhcoe/arrow-adbc into dev/go-flight-sql-in…
1891827
clean up after merge; multi-environment support for sample data
1c4e3b2
fix json element
fbd8e87
add support for SQLite
7fc08cc
Update csharp/src/Drivers/Interop/FlightSql/copyFlightSqlDriver.sh
davidhcoe 86d415a
PR feedback
844c015
re-add original FlightSql C# driver; differentiate config environment…
333e645
merge latest
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
csharp/src/Drivers/Interop/FlightSql/Apache.Arrow.Adbc.Drivers.Interop.FlightSql.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
63
csharp/src/Drivers/Interop/FlightSql/Build-FlightSqlDriver.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
80
csharp/src/Drivers/Interop/FlightSql/FlightSqlDriverLoader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.