CurtHagenlocher opened a new pull request, #4885:
URL: https://github.com/apache/arrow-adbc/pull/4885
## What's changed
This adds the ADBC 1.1 APIs to the main C# base classes (`AdbcDriver`,
`AdbcDatabase`, `AdbcConnection` and `AdbcStatement`). They also work
across the C boundary in both directions: a managed driver can be
exported as an ADBC 1.1 driver, and an imported 1.1 driver works through
the base classes.
Until now, 1.1 support lived in separate `*11` types that nothing
implemented. Adding the APIs to the existing classes means every driver
gets them without changing its base class. The `*11` types are now
marked `[Obsolete]`.
This is the second of several PRs. The first, #4884, fixed bugs in the
importer and exporter. Async methods with `CancellationToken` support
come next, then the Client changes and wider DuckDB tests.
### Backwards compatibility
Every new member is virtual and has a default implementation, so
existing drivers compile and behave as before:
- The typed setters (`SetOptionInt64`, `SetOptionDouble`) convert the
value to a string and call `SetOption(string, string)`. The typed
getters parse the result of `GetOption(string)`. Binary options throw
`NotImplemented` unless the driver overrides them.
- `GetOption` throws `NotFound` by default. On `AdbcConnection`, it
instead answers the standard options (autocommit, read-only, isolation
level, current catalog and current schema) from the existing
properties.
- `AdbcDriver.Open(IReadOnlyDictionary<string, object>)` used to throw.
It now converts values to strings and calls the string overload, then
applies any binary values through `SetOptionBytes`.
- No existing method gets a new overload that changes how existing calls
bind. That's why typed connection options use a new name,
`ConnectWithTypedOptions`. A `Connect` overload would make existing
`Connect(null)` calls ambiguous.
### New APIs
- **Typed options** at all three levels:
- `SetOptionInt64`, `SetOptionDouble` and `SetOptionBytes`.
- `GetOption`, `GetOptionInt64`, `GetOptionDouble` and
`GetOptionBytes`.
- **`AdbcDatabase.SetOption(string, object)`** sends each value to the
matching typed setter.
- **`AdbcDatabase.ConnectWithTypedOptions`** connects with options that
aren't all strings.
- **`AdbcConnection.CurrentCatalog` and `CurrentDbSchema`** properties.
- **`AdbcException.Details`** for ADBC 1.1 error details.
- `AdbcDriver.DriverVersion` is now documented.
### C interop
- **Exporter:** a managed driver exported through `CAdbcDriverExporter`
now provides the 1.1 driver functions:
- option getters and setters at every level
- `ErrorGetDetailCount` and `ErrorGetDetail`
- `ConnectionGetStatistics` and `ConnectionGetStatisticNames`
- `StatementExecuteSchema`
- `ConnectionCancel` and `StatementCancel`
Options set before `DatabaseInit` or `ConnectionInit` are stored with
their types, and are passed on when the object is created.
`OperationCanceledException` is reported as
`ADBC_STATUS_CANCELLED`.
- **Importer:** an imported driver's 1.1 functions are reachable through
the base classes. For a 1.0 driver, the importer falls back to 1.0
behavior: typed setters become string options, and getters report
`NotFound`. `GetOption` follows the C API's buffer protocol, retrying
with a larger buffer when the first one is too small.
## Testing
- **`BaseClassDefaultsTests`:** the default implementations on the base
classes, using drivers that override only the 1.0 members.
- **`ExportedDriverRoundTrip11Tests`:** a managed 1.1 driver is exported
and imported again, then exercised through the base classes. This
covers:
- typed options at each level, before and after init
- error details, vendor codes, statistics, partitions and updates
- cancellation of a running statement
- the importer's fallbacks for a 1.0 driver
- **AoT interop tests:** the native AoT fixture driver now implements
1.1 typed options and error details, and the tests use them through
the C API.
- **Results:**
- The full solution builds without warnings, and
`dotnet format --verify-no-changes` is clean.
- The core test project passes on net10.0, net8.0 and net472.
- The AoT interop tests pass against a fixture published from this
branch.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WWRrCH8uXJhAvRpEHWeadU
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]