Skip to content

go/adbc/sqldriver: read from union types #2636

@murfffi

Description

@murfffi

What feature or improvement would you like to see?

It will be nice to support reading from union columns from databases that support them when using the database/sql adapter.

For example, in DuckDB, this should work:

// Register "duckdb" as described in https://pkg.go.dev/github.com/apache/arrow-adbc/go/adbc/sqldriver
// Error handling and closing resources omitted for brevity
db, err := sql.Open("duckdb", "")
_, err = db.Exec("create table test(a union(u varchar, v int))")
_, err = db.Exec("insert into test values('aba'),(2)")
rows, err := db.Query("select * from test")
for rows.Next() {
	var s any
	err = rows.Scan(&s)
        fmt.Println(s)        
}
if rows.Err() != nil {
   fmt.Println(rows.Err())
}

This should print:

aba
2

but currently prints:

Not Implemented: not yet implemented populating from columns of type sparse_union<u: type=utf8, nullable=0, v: type=int32, nullable=1>

I have a draft PR ready if the enhancement makes sense.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions