Skip to content
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

refactor(go/adbc/driver): add common connection implementation #1572

Closed
wants to merge 1 commit into from

Conversation

lidavidm
Copy link
Member

Fixes #1105.

@github-actions github-actions bot added this to the ADBC Libraries 0.11.0 milestone Feb 29, 2024
@lidavidm
Copy link
Member Author

CC @zeroshade this only ports the Flight SQL side but if it seems reasonable enough I'll port the Snowflake side too. (For Snowflake, I plan to have it use its own GetObjects impl just because it's too different, but I figure in general it's easier to have drivers implement the Flight SQL GetCatalogs/GetDbSchemas/GetTables trinity and let the common driver code assemble the GetObjects structure)

Copy link
Member

@zeroshade zeroshade left a comment

Choose a reason for hiding this comment

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

we should probably move driverbase under an internal package so that we're not exposing it directly to consumers.

Comment on lines +59 to +80
// Will be called at most once
Close() error
// Will not be called unless autocommit is disabled
Commit(context.Context) error
CurrentCatalog() (string, bool)
CurrentDbSchema() (string, bool)
// Get boxed values for info codes
GetInfo(ctx context.Context, infoCodes []adbc.InfoCode) (map[adbc.InfoCode]interface{}, error)
// Get all info codes the driver supports (minus the 6 standard codes
// which are assumed to always be supported)
GetInfoCodes() []adbc.InfoCode
// Get all catalogs
GetObjectsCatalogs(ctx context.Context, catalog *string) ([]string, error)
GetObjectsDbSchemas(ctx context.Context, depth adbc.ObjectDepth, catalog *string, schema *string, metadataRecords []internal.Metadata) (map[string][]string, error)
GetObjectsTables(ctx context.Context, depth adbc.ObjectDepth, catalog *string, schema *string, tableName *string, columnName *string, tableType []string, metadataRecords []internal.Metadata) (map[internal.CatalogAndSchema][]internal.TableInfo, error)
GetTableSchema(ctx context.Context, catalog, dbSchema *string, tableName string) (*arrow.Schema, error)
GetTableTypes(ctx context.Context) (array.RecordReader, error)
NewStatement() (adbc.Statement, error)
ReadPartition(ctx context.Context, serializedPartition []byte) (array.RecordReader, error)
// Will not be called unless autocommit is disabled
Rollback(context.Context) error
SetAutocommit(enabled bool) error
Copy link
Member

Choose a reason for hiding this comment

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

can't this just be a composition using adbc.Connection ?

type ConnectionImpl interface {
    adbc.GetSetOptions
    Base() *ConnectionImplBase
    adbc.Connection
}

Or am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Some of the methods are different, e.g. GetInfo and the GetObjects functions

Comment on lines +108 to +114
func (base *ConnectionImplBase) Close() error {
return nil
}

func (base *ConnectionImplBase) Commit() error {
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Rather than implementing these, why not leave them unimplemented forcing anything that uses ConnectionImplBase to still need to implement them, so we don't accidentally forget them?

Copy link
Member Author

Choose a reason for hiding this comment

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

See discussion in other PR - maybe we can panic (for Close) or return an error (for Commit) instead so that it satisfies the interface by default but obviously blows up?

@lidavidm lidavidm closed this Mar 14, 2024
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.

go: extend driver framework to cover connections
2 participants