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

Issue with Appender and MotherDuck: "DuckTransaction::Get called on non-DuckDB transaction" #332

Open
Dimirolz opened this issue Dec 15, 2024 · 0 comments

Comments

@Dimirolz
Copy link

Hi,

I'm working on integrating go-duckdb with MotherDuck, and while I'm not entirely sure if the Appender functionality is officially supported in this context, I couldn’t find any information suggesting it shouldn't be.

However, when I try to use the Appender, I encounter the following error:

panic: database/sql/driver: duckdb error: DuckTransaction::Get called on non-DuckDB transaction
        could not close appender: appended data has been invalidated due to corrupt row

goroutine 1 [running]:
main.main()
        /home/dima/projects/motherduck-appender-repro/main.go:23 +0x1ab
exit status 2

To reproduce the issue, the simplest code looks like this:

package main

import (
	"context"
	"database/sql"
	"fmt"

	"github.com/marcboeker/go-duckdb"
)

func main() {
	connector, _ := duckdb.NewConnector("md:example?motherduck_token=<access_token>", nil)
	db := sql.OpenDB(connector)
	db.Exec(`CREATE TABLE IF NOT EXISTS example (
		num INTEGER
	);`)
	conn, _ := connector.Connect(context.Background())
	appender, _ := duckdb.NewAppenderFromConn(conn, "", "example")
	appender.AppendRow(2)
	err := appender.Close()
	if err != nil {
		panic(err)
	}

	var num int
	db.QueryRow(`SELECT num FROM example;`).Scan(&num)

	fmt.Println(num)
}

Steps to Reproduce:

  1. Use the provided code snippet.
  2. Run it with MotherDuck as the backend (md:example?motherduck_token=<access_token>).
  3. Observe the panic during appender.Close().

Expected Behavior:

The Appender should append the row to the specified table and close gracefully without errors.

Actual Behavior:
The application panics during the appender.Close() call with the error message provided above.

Environment:

Go Version: go version go1.23.4 linux/amd64
Library Version: github.com/marcboeker/go-duckdb v1.8.3
Backend: MotherDuck
Additional Context:
I’d like to confirm whether the Appender is expected to work with MotherDuck. If not, it would be helpful to document its limitations in this context.

Thanks in advance for your help!

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

No branches or pull requests

1 participant