Skip to content

feat(csharp): implement transaction support#217

Merged
CurtHagenlocher merged 2 commits into
adbc-drivers:mainfrom
CurtHagenlocher:CSharpTransaction
Jun 17, 2026
Merged

feat(csharp): implement transaction support#217
CurtHagenlocher merged 2 commits into
adbc-drivers:mainfrom
CurtHagenlocher:CSharpTransaction

Conversation

@CurtHagenlocher

Copy link
Copy Markdown
Collaborator

What's Changed

Add BigQuery session-based transaction support to the C# ADBC driver, matching the existing Go implementation pattern:

  • BigQueryConnection: Add AutoCommit property override that creates/closes BigQuery sessions, and Commit/Rollback methods that issue COMMIT/ROLLBACK TRANSACTION and immediately BEGIN a new transaction
  • BigQueryStatement: Pass session_id via ConnectionProperties in QueryOptions when a transaction is active, for both ExecuteQuery and ExecuteUpdate
  • Tracing: Add session_id tags and lifecycle events (session_created, session_closed, transaction_started, transaction_committed, transaction_rolled_back) to all transaction operations and session-aware query execution via DiagnosticSource Activity tracing
  • BigQueryMockServer: Add session tracking, parse CreateSession and ConnectionProperties from job requests, return SessionInfo in job stats
  • TransactionTests: 11 mock server tests covering the full transaction lifecycle (enable/disable autocommit, commit, rollback, error cases, dispose)
  • TransactionLiveTests: 5 live integration tests (skipped without credentials) covering commit persistence, rollback discard, multiple commits, and error cases against a real BigQuery instance

Add BigQuery session-based transaction support to the C# ADBC driver,
matching the existing Go implementation pattern:

- BigQueryConnection: Add AutoCommit property override that creates/closes
  BigQuery sessions, and Commit/Rollback methods that issue COMMIT/ROLLBACK
  TRANSACTION and immediately BEGIN a new transaction
- BigQueryStatement: Pass session_id via ConnectionProperties in QueryOptions
  when a transaction is active, for both ExecuteQuery and ExecuteUpdate
- Tracing: Add session_id tags and lifecycle events (session_created,
  session_closed, transaction_started, transaction_committed,
  transaction_rolled_back) to all transaction operations and
  session-aware query execution via DiagnosticSource Activity tracing
- BigQueryMockServer: Add session tracking, parse CreateSession and
  ConnectionProperties from job requests, return SessionInfo in job stats
- TransactionTests: 11 mock server tests covering the full transaction
  lifecycle (enable/disable autocommit, commit, rollback, error cases, dispose)
- TransactionLiveTests: 5 live integration tests (skipped without credentials)
  covering commit persistence, rollback discard, multiple commits, and error
  cases against a real BigQuery instance

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds BigQuery session-based transaction support to the C# ADBC driver (aligning with the Go driver’s approach), including session lifecycle management, session-aware query execution, and corresponding mock/live test coverage.

Changes:

  • Implement session-backed AutoCommit, Commit(), and Rollback() behavior in BigQueryConnection using CreateSession, BEGIN/COMMIT/ROLLBACK TRANSACTION, and BQ.ABORT_SESSION.
  • Propagate session_id via ConnectionProperties in BigQueryStatement so queries/updates execute within the active transaction session.
  • Extend the mock server to parse/return session info and add mock + live test suites to validate the transaction lifecycle.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
csharp/src/AdbcDrivers.BigQuery/BigQueryConnection.cs Implements session creation/teardown and transaction commands behind AutoCommit/Commit/Rollback.
csharp/src/AdbcDrivers.BigQuery/BigQueryStatement.cs Attaches session_id connection properties to query/update jobs when a transaction is active.
csharp/test/AdbcDrivers.BigQuery.MockServer/BigQueryMockServer.cs Adds session parsing/creation and records executed SQL for transaction-related assertions.
csharp/test/AdbcDrivers.BigQuery.Tests/MockServer/TransactionTests.cs Adds mock-server tests covering autocommit toggling and commit/rollback behavior.
csharp/test/AdbcDrivers.BigQuery.Tests/TransactionLiveTests.cs Adds live integration tests validating commit persistence and rollback discard semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread csharp/src/AdbcDrivers.BigQuery/BigQueryConnection.cs
Comment thread csharp/test/AdbcDrivers.BigQuery.Tests/TransactionLiveTests.cs
Comment thread csharp/test/AdbcDrivers.BigQuery.Tests/MockServer/TransactionTests.cs Outdated
@CurtHagenlocher CurtHagenlocher merged commit d0359b5 into adbc-drivers:main Jun 17, 2026
4 checks passed
@CurtHagenlocher CurtHagenlocher deleted the CSharpTransaction branch June 17, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants