feat(csharp): httpPath-based protocol auto-detection (PECO-3055) [SEA] - #467
Open
eric-wang-1990 wants to merge 1 commit into
Open
feat(csharp): httpPath-based protocol auto-detection (PECO-3055) [SEA]#467eric-wang-1990 wants to merge 1 commit into
eric-wang-1990 wants to merge 1 commit into
Conversation
Match JDBC's compute-type-based protocol selection
(DatabricksConnectionContext.getClientTypeFromContext) so the C# driver
defaults to SEA for warehouse paths and forces Thrift for GP-cluster paths
when adbc.databricks.protocol is not set explicitly.
Resolution order (DatabricksDatabase.ResolveProtocol):
1. Explicit adbc.databricks.protocol value wins (case-insensitive).
2. Else inspect httpPath:
- matches .*/o/.+/.+ -> "thrift" (GP cluster forced)
- matches .*/warehouses/.+ or .*/endpoints/.+ -> "rest" (SEA default)
3. Else fall back to "thrift" (preserves pre-3055 behavior for callers
that omit httpPath, e.g. some integration-test fixtures).
Also adds the SEA -> Thrift fallback on HTTP 307 from createSession,
mirroring JDBC's DatabricksSession.open() handling of
DatabricksTemporaryRedirectException. The fallback is gated on auto-
detected protocol — explicit "rest" surfaces the 307 to the caller so
the SEA-not-available signal is not silently swallowed.
Test changes:
- New csharp/test/E2E/ProtocolAutoDetectionE2ETests.cs covers all three
resolution paths (warehouse-default-SEA, explicit-thrift-override,
explicit-rest, GP-cluster-forces-thrift). Red proof captured against
the pecotesting warehouse: IsType<StatementExecutionConnection> failed
with "Actual: typeof(DatabricksConnection)". Green after fix.
- DatabricksTestEnvironment.IsResolvedProtocolRest helper centralizes
the "is this run effectively SEA?" check for existing Skip.If guards
that previously compared TestConfiguration.Protocol to the literal
"rest" (which silently misses the auto-detected case). 19 existing
tests' Skip.If predicates are updated to use it; same skip semantics
as before, just correct for the new default.
PECO-3055
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's Changed
Matches JDBC's compute-type-based protocol selection (
DatabricksConnectionContext.getClientTypeFromContext) so the C# driver defaults to SEA for warehouse paths and forces Thrift for GP-cluster paths whenadbc.databricks.protocolis not set explicitly. Adds the SEA → Thrift fallback on HTTP 307 fromcreateSession, mirroring JDBC'sDatabricksSession.open()handling ofDatabricksTemporaryRedirectException.Resolution order in new
DatabricksDatabase.ResolveProtocol:adbc.databricks.protocolvalue wins (case-insensitive)..*/o/.+/.+→"thrift"(GP cluster forced).*/warehouses/.+or.*/endpoints/.+→"rest"(SEA default)"thrift"(preserves pre-3055 behavior for callers that omit httpPath, e.g. some integration-test fixtures).The 307 fallback is gated on auto-detected protocol — explicit
"rest"surfaces the 307 to the caller so the SEA-not-available signal is not silently swallowed.Why
PECO-3055 — M3 explicit deliverable for the SEA-as-default rollout. Without this, the C# driver always defaults to Thrift even on warehouse paths, which is inconsistent with JDBC.
Red → Green proof
Ran against the live
pecotestingwarehouse (/sql/1.0/warehouses/2f03dd43e35e2aa0).Before fix (
WarehousePath_DefaultsToSeaProtocol_WhenProtocolNotSpecified):After fix:
Full
DatabricksConnectionTestregression run (the largest adjacent class):The 6 skips are tests that were previously skipped via
TestConfiguration.Protocol == "rest"and now correctly skip via the newDatabricksTestEnvironment.IsResolvedProtocolResthelper (same semantics, just correct for the new default).Files touched
csharp/src/DatabricksDatabase.cs— newResolveProtocol,IsTemporaryRedirectError,OpenThriftConnection, andGetHttpPathhelpers;Connect()uses them.csharp/test/E2E/ProtocolAutoDetectionE2ETests.cs(new) — four E2E tests covering warehouse-default-SEA, explicit-thrift-override, explicit-rest, GP-cluster-forces-thrift.csharp/test/E2E/DatabricksTestEnvironment.cs— addsIsResolvedProtocolReststatic helper.Skip.If(TestConfiguration.Protocol == "rest", ...)predicates replaced withSkip.If(DatabricksTestEnvironment.IsResolvedProtocolRest(TestConfiguration), ...)so they still skip when the resolved (not just explicit) protocol is SEA. Mechanical change, no test semantics altered.Manual verification
ProtocolAutoDetectionE2ETestspasses against pecotesting warehouse (4/4)DatabricksConnectionTestadjacent regression run passes (86 pass / 6 correctly skipped)DriverTestssmoke run passes (34 pass / 1 skipped)netstandard2.0andnet8.0(no warnings, no errors)net8.0setuptoolsfrom PyPI. Ruff/codespell hooks are Python-only and do not touch the C# files in this PR.PECO-3055
This PR was created with GitHub MCP.