-
Notifications
You must be signed in to change notification settings - Fork 16
feat(csharp): native C# Snowflake ADBC driver (REST-based) #171
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
Open
ndglover
wants to merge
7
commits into
adbc-drivers:main
Choose a base branch
from
ndglover:initial
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
7 commits
Select commit
Hold shift + click to select a range
89a8843
feat(csharp): native C# Snowflake ADBC driver (REST-based)
ndglover 9be9c94
fix(csharp): dispose previously bound parameters on re-bind
ndglover 6183015
fix(csharp): reject unparseable connection parameters instead of igno…
ndglover 2d0cfbe
chore(csharp): add missing license headers to native driver files
ndglover 153b6da
chore(csharp): add .editorconfig and format native driver
ndglover a65e099
chore(csharp): fix linting
ndglover bfeac75
chore(csharp): correct license headers on original native driver files
ndglover 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 hidden or 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,15 @@ | ||
| # Copyright (c) 2025 ADBC Drivers Contributors | ||
| # | ||
| # Licensed 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. | ||
|
|
||
| * text=auto eol=lf |
This file contains hidden or 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 hidden or 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,43 @@ | ||
| # Copyright (c) 2025 ADBC Drivers Contributors | ||
| # | ||
| # Licensed 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. | ||
|
|
||
| # EditorConfig for the C# workspace: the native Snowflake driver and its tests. | ||
| # | ||
| # Layout rules (whitespace, line endings, brace placement) are enforced so `dotnet format` | ||
| # is deterministic. Semantic style preferences (var, expression bodies) are documented at | ||
| # `silent` severity: they guide the IDE but are intentionally NOT auto-rewritten by | ||
| # `dotnet format`, so the tool never churns hand-written code. | ||
| root = true | ||
|
|
||
| [*] | ||
| charset = utf-8 | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
| indent_style = space | ||
| indent_size = 4 | ||
|
|
||
| [*.{json,yml,yaml}] | ||
| indent_size = 2 | ||
|
|
||
| [*.cs] | ||
| csharp_indent_case_contents = true | ||
| csharp_indent_case_contents_when_block = false | ||
|
|
||
| # Preferences the codebase follows, documented but not machine-enforced (silent = no format churn). | ||
| csharp_style_namespace_declarations = file_scoped:silent | ||
| csharp_style_var_for_built_in_types = true:silent | ||
| csharp_style_var_when_type_is_apparent = true:silent | ||
| csharp_style_var_elsewhere = true:silent | ||
| dotnet_style_require_accessibility_modifiers = never:silent |
This file contains hidden or 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 hidden or 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 hidden or 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,135 @@ | ||
| # Copyright (c) 2025 ADBC Drivers Contributors | ||
| # | ||
| # Licensed 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. | ||
|
|
||
| # Benchmark runner: native C# driver vs Go/Interop driver. Both projects expose an | ||
| # identically-shaped BenchmarkTests.BaselineQueryPerformance; this runs each suite 5 | ||
| # times and parses the per-limit timings (the [NATIVE]/[INTEROP] log lines). | ||
|
|
||
| $ErrorActionPreference = "Stop" | ||
|
|
||
| # Determine the repository root from the location of this script. | ||
| # Assumes this script lives in the repository root. If you move it into | ||
| # a subdirectory (e.g. scripts\), change this to: | ||
| # $repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..") | ||
| $repoRoot = $PSScriptRoot | ||
|
|
||
| # Resolve project paths | ||
| $nativeProject = Join-Path $repoRoot "test\Native\AdbcDrivers.Snowflake.Native.Tests.csproj" | ||
| $interopProject = Join-Path $repoRoot "test\Interop\AdbcDrivers.Snowflake.Interop.Tests.csproj" | ||
|
|
||
| # Use an existing SNOWFLAKE_TEST_CONFIG_FILE environment variable if present. | ||
| # Otherwise prompt the user for the config file. | ||
| if (-not $env:SNOWFLAKE_TEST_CONFIG_FILE) { | ||
| $env:SNOWFLAKE_TEST_CONFIG_FILE = Read-Host "Enter the full path to snowflakeconfig.local.json" | ||
| } | ||
|
|
||
| if (-not (Test-Path $env:SNOWFLAKE_TEST_CONFIG_FILE)) { | ||
| throw "Snowflake config file not found: '$($env:SNOWFLAKE_TEST_CONFIG_FILE)'" | ||
| } | ||
|
|
||
| Write-Host "Using Snowflake config: $env:SNOWFLAKE_TEST_CONFIG_FILE" | ||
|
|
||
| $outDir = Join-Path $env:TEMP "adbc_bench" | ||
| New-Item -ItemType Directory -Force -Path $outDir | Out-Null | ||
| Get-ChildItem $outDir -Filter *.txt -ErrorAction SilentlyContinue | Remove-Item -Force | ||
|
|
||
| $runs = 5 | ||
|
|
||
| Write-Output "########## NATIVE (C#) driver — BenchmarkTests ##########" | ||
| for ($i = 1; $i -le $runs; $i++) { | ||
| Write-Output "---- native run $i/$runs ----" | ||
| dotnet test $nativeProject -c Release --no-build ` | ||
| --filter "FullyQualifiedName~BenchmarkTests.BaselineQueryPerformance" ` | ||
| --logger "console;verbosity=detailed" 2>&1 | | ||
| Tee-Object -FilePath "$outDir\native_$i.txt" | Out-Null | ||
| } | ||
|
|
||
| Write-Output "########## INTEROP (Go) driver — BenchmarkTests ##########" | ||
| for ($i = 1; $i -le $runs; $i++) { | ||
| Write-Output "---- interop run $i/$runs ----" | ||
| dotnet test $interopProject -c Release --no-build ` | ||
| --filter "FullyQualifiedName~BenchmarkTests.BaselineQueryPerformance" ` | ||
| --logger "console;verbosity=detailed" 2>&1 | | ||
| Tee-Object -FilePath "$outDir\interop_$i.txt" | Out-Null | ||
| } | ||
|
|
||
| # ---- parse ---- | ||
| function Get-Timings($glob) { | ||
| $map = @{} | ||
| foreach ($f in Get-ChildItem $outDir -Filter $glob) { | ||
| foreach ($line in Get-Content $f.FullName) { | ||
| if ($line -match 'for limit (\d+) in (\d+) ms') { | ||
| $limit = [int]$Matches[1] | ||
| $ms = [int]$Matches[2] | ||
| if (-not $map.ContainsKey($limit)) { | ||
| $map[$limit] = @() | ||
| } | ||
| $map[$limit] += $ms | ||
| } | ||
| } | ||
| } | ||
| return $map | ||
| } | ||
|
|
||
| function Show-Stats($name, $map) { | ||
| Write-Output "" | ||
| Write-Output "===== $name =====" | ||
| foreach ($limit in ($map.Keys | Sort-Object)) { | ||
| $vals = $map[$limit] | ||
| $mean = [math]::Round(($vals | Measure-Object -Average).Average, 0) | ||
| $min = ($vals | Measure-Object -Minimum).Minimum | ||
| $max = ($vals | Measure-Object -Maximum).Maximum | ||
|
|
||
| if ($vals.Count -gt 1) { | ||
| $sd = [math]::Round( | ||
| [math]::Sqrt( | ||
| (($vals | | ||
| ForEach-Object { [math]::Pow($_ - $mean, 2) } | | ||
| Measure-Object -Sum).Sum) / ($vals.Count - 1) | ||
| ), | ||
| 0 | ||
| ) | ||
| } | ||
| else { | ||
| $sd = 0 | ||
| } | ||
|
|
||
| $joined = ($vals -join ', ') | ||
| Write-Output ("limit {0,8}: n={1} mean={2,7} ms min={3,7} max={4,7} sd={5,6} [{6}]" -f $limit, $vals.Count, $mean, $min, $max, $sd, $joined) | ||
| } | ||
| } | ||
|
|
||
| Write-Output "" | ||
| Write-Output "==================== RESULTS ====================" | ||
|
|
||
| $nat = Get-Timings "native_*.txt" | ||
| $intr = Get-Timings "interop_*.txt" | ||
|
|
||
| Show-Stats "NATIVE (C#)" $nat | ||
| Show-Stats "INTEROP (Go)" $intr | ||
|
|
||
| Write-Output "" | ||
| Write-Output "===== mean comparison (native / interop) =====" | ||
|
|
||
| foreach ($limit in ($nat.Keys | Sort-Object)) { | ||
| if ($intr.ContainsKey($limit)) { | ||
| $nm = ($nat[$limit] | Measure-Object -Average).Average | ||
| $im = ($intr[$limit] | Measure-Object -Average).Average | ||
| $ratio = [math]::Round($nm / $im, 2) | ||
|
|
||
| Write-Output ("limit {0,8}: native {1,7} ms vs interop {2,7} ms ratio={3}x" -f $limit, [math]::Round($nm, 0), [math]::Round($im, 0), $ratio) | ||
| } | ||
| } | ||
|
|
||
| Write-Output "DONE" |
This file contains hidden or 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,30 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <PackageReadmeFile>readme.md</PackageReadmeFile> | ||
| <Description>Native C# Snowflake driver for Apache Arrow ADBC</Description> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <!-- Abstractions only: the driver consumes ILogger/ILoggerFactory but never builds a provider. | ||
| JWT (key-pair auth) is hand-rolled over the in-box System.Security.Cryptography RSA. --> | ||
| <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\arrow-adbc\csharp\src\Apache.Arrow.Adbc\Apache.Arrow.Adbc.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <InternalsVisibleTo Include="AdbcDrivers.Snowflake.Native.Tests" /> | ||
| <InternalsVisibleTo Include="DynamicProxyGenAssembly2" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Content Include="readme.md"> | ||
| <Pack>true</Pack> | ||
| <PackagePath>\</PackagePath> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </Content> | ||
| </ItemGroup> | ||
| </Project> |
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.
I thought certain IDE files used CRLF?
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 found that by not fixing it to one or the other you end up with certain IDEs automatically modifying the files. This means you need to manually handle this in git by reverting these changes or you end up in ding dong between different conventions people have. I believe fixing to one works better but open to other suggestions