marcboeker / go-duckdb

go-duckdb provides a database/sql driver for the DuckDB database engine.
MIT License
579 stars 90 forks source link

Appending a NULL in UUID[] column panics #214

Open disq opened 1 month ago

disq commented 1 month ago

I thought with https://github.com/marcboeker/go-duckdb/pull/193 for nulls we'd have to use untyped nils for NULL values, doing so doesn't seem to work for uuid[] columns.

panic: interface conversion: interface {} is nil, not duckdb.UUID

goroutine 23 [running]:
github.com/marcboeker/go-duckdb.(*vector).init.(*vector).initUUID.func15(0x1400163a410?, 0x0?, {0x0?, 0x0?})
    /user/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.4/appender_vector.go:393 +0x98
github.com/marcboeker/go-duckdb.(*vector).setList(0x1400163a3c0, 0x0, {0x1075199e0?, 0x14001c8c510?})
    /user/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.4/appender_vector.go:333 +0x164
github.com/marcboeker/go-duckdb.(*vector).initList.func3(0x14001aecb90?, 0x107518de0?, {0x1075199e0?, 0x14001c8c510?})
    /user/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.4/appender_vector.go:426 +0x24
github.com/marcboeker/go-duckdb.(*Appender).appendRowSlice(0x140000d6090, {0x14000af4008, 0xbd, 0xbd?})
    /user/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.4/appender.go:205 +0x114
github.com/marcboeker/go-duckdb.(*Appender).AppendRow(0x107806fd8?, {0x14000af4008?, 0x140005f2808?, 0xbd?})
    /user/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.4/appender.go:142 +0x28

I tried a typed nil (of *duckdb.UUID) which gave me: database/sql/driver: could not append row: cast error: cannot cast *duckdb.UUID to duckdb.UUID: column index: 47

So, what's the correct way to insert nulls using appender?

taniabogatsch commented 1 month ago

Hi @disq. Could you add a self-contained Go program to reproduce this, please? Then I can have a look