Skip to content

feat(sqlwrapper): allow extending statement implementation#170

Open
lidavidm wants to merge 1 commit into
mainfrom
dev
Open

feat(sqlwrapper): allow extending statement implementation#170
lidavidm wants to merge 1 commit into
mainfrom
dev

Conversation

@lidavidm
Copy link
Copy Markdown
Contributor

@lidavidm lidavidm commented Jun 2, 2026

No description provided.

@lidavidm lidavidm marked this pull request as ready for review June 2, 2026 07:21
@lidavidm lidavidm requested a review from amoeba June 2, 2026 07:24
@lidavidm
Copy link
Copy Markdown
Contributor Author

lidavidm commented Jun 2, 2026

@amoeba see adbc-drivers/trino#86 and adbc-drivers/trino#84 for context here

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors sqlwrapper’s statement implementation to be extensible by downstream drivers, enabling driver-specific statement wrappers (via a statement factory) and allowing drivers to inject additional Exec/Query parameters.

Changes:

  • Introduces a new StatementImpl interface plus StatementImplBase wrapper to support customizable statement implementations.
  • Adds StatementFactory and plumbing (Driver.WithStatementFactory, databaseImpl.stmtFactory, ConnectionImplBase.dbImpl) to construct custom statements.
  • Propagates driver-provided “additional exec params” into update/query execution paths and the record reader.

Reviewed changes

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

File Description
sqlwrapper/statement.go Reworks statement implementation into an extensible base + interface, wires in statement factory, and threads additional exec params through execution/bulk ingest paths.
sqlwrapper/record_reader.go Adds support for appending driver-provided additional exec params when executing queries.
sqlwrapper/driver.go Adds StatementFactory support to the driver and passes it into databaseImpl.
sqlwrapper/connection.go Stores a pointer to databaseImpl on connections and updates statement construction to return an error.

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

Comment thread sqlwrapper/statement.go
Comment on lines +106 to +117
var impl StatementImpl
if c.dbImpl.stmtFactory != nil {
var err error
impl, err = c.dbImpl.stmtFactory.CreateStatement(wrapper)
if err != nil {
return nil, err
}
} else {
impl = wrapper
}
wrapper.Derived = impl
return driverbase.NewStatement(impl), nil
Comment thread sqlwrapper/statement.go
Comment on lines 152 to +156
size, err := strconv.Atoi(val)
if err != nil {
return s.Base().ErrorHelper.InvalidArgument("invalid batch size: %v", err)
}
return s.SetBatchSize(size)
return s.SetBatchSize(int64(size))
Comment thread sqlwrapper/statement.go
Comment on lines 526 to 528
quotedTableName := ingester.QuoteIdentifier(options.TableName)
params := stmtImpl.GetAdditionalExecParams()

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.

2 participants