Skip to content

Commit

Permalink
refactor(go/adbc/driver): driverbase implementation for connection (#…
Browse files Browse the repository at this point in the history
…1590)

Implementation of Connection driver base, along with a refactor of
Driver and Database bases.

The bases have been refactored in the following way:
- The `*Impl` interface (e.g. `DatabaseImpl`) now explicitly implements
the corresponding `adbc` interface (e.g. `adbc.Database`).
- We now check to guarantee the `DatabaseImplBase` implements the entire
`DatabaseImpl` interface with stub methods or default implementations.
- A new interface has been added (e.g. `driverbase.Database`) which
contains all methods the _output_ of driverbase constructor
`NewDatabase()` should be. This helps document and guarantee the "extra"
behavior provided by using the driverbase. This interface should be
internal to the library.
- By embedding `DatabaseImpl` in the `database` struct (and similarly
for the other bases) it automatically inherits implementations coming
from the `DatabaseImpl`. This way we don't need to write out all the
implementations a second time, hence the deletes.
- The Connection base uses a builder for its constructor to register any
helper methods (see discussion in comments). The Driver and Database
bases use simple function constructors because they don't have any
helpers to register. This felt simpler but I can make those into trivial
builders as well if we prefer to have consistency between them.

A new `DriverInfo` type has been introduced to help consolidate the
collection and validation of metadata for `GetInfo()`.

There are more small changes such as refactors of the flightsql and
snowflake drivers to make use of the added functionality, as well as a
new set of tests for the driverbase. Please let me know if anything else
could use clarification.

Resolves #1105.
  • Loading branch information
joellubi committed Mar 19, 2024
1 parent acac557 commit 3022428
Show file tree
Hide file tree
Showing 21 changed files with 1,861 additions and 846 deletions.
11 changes: 11 additions & 0 deletions go/adbc/adbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,17 @@ const (
InfoDriverADBCVersion InfoCode = 103 // DriverADBCVersion
)

type InfoValueTypeCode = arrow.UnionTypeCode

const (
InfoValueStringType InfoValueTypeCode = 0
InfoValueBooleanType InfoValueTypeCode = 1
InfoValueInt64Type InfoValueTypeCode = 2
InfoValueInt32BitmaskType InfoValueTypeCode = 3
InfoValueStringListType InfoValueTypeCode = 4
InfoValueInt32ToInt32ListMapType InfoValueTypeCode = 5
)

type ObjectDepth int

const (
Expand Down
66 changes: 0 additions & 66 deletions go/adbc/driver/driverbase/driver.go

This file was deleted.

Loading

0 comments on commit 3022428

Please sign in to comment.