Skip to content

Commit

Permalink
build(csharp): script build, test, package and smoke test (apache#1345)
Browse files Browse the repository at this point in the history
Down payment toward apache#1121:

- Structures the projects for NuGet packaging

---------

Co-authored-by: David Coe <[email protected]>
  • Loading branch information
davidhcoe and David Coe authored Dec 12, 2023
1 parent cf3b5c0 commit fd705e0
Show file tree
Hide file tree
Showing 36 changed files with 466 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ adbc.h @lidavidm

## Implementations
/c/ @lidavidm
/csharp/ @lidavidm
/csharp/ @lidavidm @CurtHagenlocher
/glib/ @kou
/java/ @lidavidm
/go/ @zeroshade
Expand Down
1 change: 1 addition & 0 deletions csharp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ x64

artifacts/
TestResults/
packages/
29 changes: 21 additions & 8 deletions csharp/Apache.Arrow.Adbc.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33403.182
Expand All @@ -25,12 +24,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Client", "Client", "{B61116
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Client", "src\Client\Apache.Arrow.Adbc.Client.csproj", "{A405F4A0-5938-4139-B2DF-ED9A05EC3D7C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Tests.Drivers.Interop.Snowflake", "test\Drivers\Snowflake\Apache.Arrow.Adbc.Tests.Drivers.Interop.Snowflake.csproj", "{DEE943D1-A2D0-40CD-ABE0-2CB38E7CA156}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Drivers.BigQuery", "src\Drivers\BigQuery\Apache.Arrow.Adbc.Drivers.BigQuery.csproj", "{A748041C-EF9A-4E88-B6FB-9F2D6CB79170}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Tests.Drivers.BigQuery", "test\Drivers\BigQuery\Apache.Arrow.Adbc.Tests.Drivers.BigQuery.csproj", "{EA43BB7C-BC00-4701-BDF4-367880C2495C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Drivers.Interop.Snowflake", "src\Drivers\Interop\Snowflake\Apache.Arrow.Adbc.Drivers.Interop.Snowflake.csproj", "{30024B6F-7BC1-4574-BE5A-924FBD6EAF83}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Tests.Drivers.Interop.Snowflake", "test\Drivers\Interop\Snowflake\Apache.Arrow.Adbc.Tests.Drivers.Interop.Snowflake.csproj", "{8BE1EECC-3ACF-41B2-AF7D-1A67196FF6C7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Flight", "src\arrow\csharp\src\Apache.Arrow.Flight\Apache.Arrow.Flight.csproj", "{0F41F702-A691-4E51-96A9-DF9813E47D8F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -61,10 +64,6 @@ Global
{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
{A405F4A0-5938-4139-B2DF-ED9A05EC3D7C}.Release|Any CPU.Build.0 = Release|Any CPU
{DEE943D1-A2D0-40CD-ABE0-2CB38E7CA156}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DEE943D1-A2D0-40CD-ABE0-2CB38E7CA156}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEE943D1-A2D0-40CD-ABE0-2CB38E7CA156}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEE943D1-A2D0-40CD-ABE0-2CB38E7CA156}.Release|Any CPU.Build.0 = Release|Any CPU
{A748041C-EF9A-4E88-B6FB-9F2D6CB79170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A748041C-EF9A-4E88-B6FB-9F2D6CB79170}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A748041C-EF9A-4E88-B6FB-9F2D6CB79170}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -73,6 +72,18 @@ Global
{EA43BB7C-BC00-4701-BDF4-367880C2495C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA43BB7C-BC00-4701-BDF4-367880C2495C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA43BB7C-BC00-4701-BDF4-367880C2495C}.Release|Any CPU.Build.0 = Release|Any CPU
{30024B6F-7BC1-4574-BE5A-924FBD6EAF83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30024B6F-7BC1-4574-BE5A-924FBD6EAF83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30024B6F-7BC1-4574-BE5A-924FBD6EAF83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30024B6F-7BC1-4574-BE5A-924FBD6EAF83}.Release|Any CPU.Build.0 = Release|Any CPU
{8BE1EECC-3ACF-41B2-AF7D-1A67196FF6C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BE1EECC-3ACF-41B2-AF7D-1A67196FF6C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BE1EECC-3ACF-41B2-AF7D-1A67196FF6C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BE1EECC-3ACF-41B2-AF7D-1A67196FF6C7}.Release|Any CPU.Build.0 = Release|Any CPU
{0F41F702-A691-4E51-96A9-DF9813E47D8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F41F702-A691-4E51-96A9-DF9813E47D8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F41F702-A691-4E51-96A9-DF9813E47D8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F41F702-A691-4E51-96A9-DF9813E47D8F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -84,9 +95,11 @@ Global
{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}
{DEE943D1-A2D0-40CD-ABE0-2CB38E7CA156} = {C7290227-E925-47E7-8B6B-A8B171645D58}
{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}
{0F41F702-A691-4E51-96A9-DF9813E47D8F} = {9ADA26E0-F328-4466-908A-2FA506DBDF7D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4795CF16-0FDB-4BE0-9768-5CF31564DC03}
Expand Down
29 changes: 29 additions & 0 deletions csharp/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
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.
-->

<Project>

<!-- The following works around https://github.com/dotnet/sourcelink/issues/572 -->
<PropertyGroup>
<TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
</PropertyGroup>
<ItemGroup>
<EmbeddedFiles Include="$(GeneratedAssemblyInfoFile)"/>
<EmbeddedFiles Include="$(TargetFrameworkMonikerAssemblyAttributesPath)"/>
</ItemGroup>

</Project>
11 changes: 8 additions & 3 deletions csharp/src/Apache.Arrow.Adbc/Apache.Arrow.Adbc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\arrow\csharp\src\Apache.Arrow\Apache.Arrow.csproj" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net5.0'))">
<Compile Remove="C\NativeLibrary.cs" />
</ItemGroup>

<ItemGroup>
<Content Include="readme.md">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions csharp/src/Apache.Arrow.Adbc/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--
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.
-->
# Apache Arrow ADBC

An implementation of Arrow ADBC targeting .NET Standard 2.0 and .NET 6 or later.
8 changes: 8 additions & 0 deletions csharp/src/Client/Apache.Arrow.Adbc.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Apache.Arrow.Adbc\Apache.Arrow.Adbc.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="readme.md">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="7.0.0" Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'" />
Expand All @@ -11,4 +12,11 @@
<ItemGroup>
<ProjectReference Include="..\..\Apache.Arrow.Adbc\Apache.Arrow.Adbc.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="readme.md">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
7 changes: 6 additions & 1 deletion csharp/src/Drivers/BigQuery/BigQueryConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -868,11 +868,16 @@ private ListArray CreateNestedListArray(List<IArrowArray> arrayList, IArrowType

public override AdbcStatement CreateStatement()
{
if (this.client == null || this.credential == null)
if (this.credential == null)
{
throw new InvalidOperationException();
}

if(this.client == null)
{
Open();
}

BigQueryStatement statement = new BigQueryStatement(this.client, this.credential);
statement.Options = ParseOptions();
return statement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Apache.Arrow.Flight" Version="12.0.0" />
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="7.0.0" Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Apache.Arrow.Adbc\Apache.Arrow.Adbc.csproj" />
<ProjectReference Include="..\..\arrow\csharp\src\Apache.Arrow.Flight\Apache.Arrow.Flight.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472;net6.0</TargetFrameworks>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>
<!-- use Build-SnowflakeDriver.ps1 to build the dll -->
<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<Exec Command="powershell -ExecutionPolicy Unrestricted -File $(ProjectDir)Build-SnowflakeDriver.ps1" />
</Target>

<!-- libadbc_driver_snowflake.dll is listed for each framework because $(TargetFramework) doesn't work here -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<Content Include="libadbc_driver_snowflake.dll">
<Pack>true</Pack>
<PackagePath>lib\netstandard2.0</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libadbc_driver_snowflake.dll">
<Pack>true</Pack>
<PackagePath>lib\net472</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libadbc_driver_snowflake.dll">
<Pack>true</Pack>
<PackagePath>lib\net6.0</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="readme.md">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Apache.Arrow.Adbc\Apache.Arrow.Adbc.csproj" />
</ItemGroup>
</Project>
36 changes: 36 additions & 0 deletions csharp/src/Drivers/Interop/Snowflake/Build-SnowflakeDriver.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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 Snowflake ADBC Go driver"

$location = Get-Location

$file = "libadbc_driver_snowflake.dll"

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

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
}
}
make $file
COPY $file $location
63 changes: 63 additions & 0 deletions csharp/src/Drivers/Interop/Snowflake/SnowflakeDriverLoader.cs
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.
*/

using System.IO;
using Apache.Arrow.Adbc.C;

namespace Apache.Arrow.Adbc.Drivers.Interop.Snowflake
{
/// <summary>
/// Lightweight class for loading the Snowflake Go driver to .NET.
/// </summary>
public class SnowflakeDriverLoader
{
/// <summary>
/// Loads the Snowflake Go driver from the current directory using the default name and entry point.
/// </summary>
/// <returns>An <see cref="AdbcDriver"/> based on the Snowflake Go driver.</returns>
/// <exception cref="FileNotFoundException"></exception>
public static AdbcDriver LoadDriver()
{
string file = "libadbc_driver_snowflake.dll";

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, "SnowflakeDriverInit");
}

/// <summary>
/// Loads the Snowflake 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 Snowflake Go driver.</returns>
public static AdbcDriver LoadDriver(string file, string entryPoint)
{
AdbcDriver snowflakeDriver = CAdbcDriverImporter.Load(file, entryPoint);

return snowflakeDriver;
}
}
}
30 changes: 30 additions & 0 deletions csharp/src/Drivers/Interop/Snowflake/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
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.
-->

# About
This project generates a NuGet package containing the Snowflake ADBC Go Driver for use in other .NET projects. It contains a lightweight loader for loading the driver.

For details, see:

[Snowflake Driver](https://arrow.apache.org/adbc/main/driver/snowflake.html) for docs

[GitHub](https://github.com/apache/arrow-adbc/tree/main/go/adbc/driver/snowflake) for source code

## Build the Snowflake Driver
Run the `Build-SnowflakeDriver.ps1` script to build the Snowflake driver.
Loading

0 comments on commit fd705e0

Please sign in to comment.