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

Appender AppendRow #328

Open
loicalleyne opened this issue Dec 9, 2024 · 2 comments
Open

Appender AppendRow #328

loicalleyne opened this issue Dec 9, 2024 · 2 comments
Labels
feature [feature] request or PR requires latest duckdb

Comments

@loicalleyne
Copy link
Contributor

Would the DuckDB's underlying C API support sending the entire row's data as a struct or map instead of breaking it down to its individual fields as is currently the case with AppendRow?

I'm dealing with several sources of nested data with a dozen or more columns each and would prefer to just pass one struct. I suppose it would involve somehow 'walking the struct' and make a slice of driver.Value to pass to AppendRow.

@taniabogatsch
Copy link
Collaborator

Hi @loicalleyne - I've been working on adding support for this to the C API. Here's a list of related PRs. We can start implementing the Go side once go-duckdb moves to the newest duckdb version. :)

Pass, e.g., a map[string]interface{} to AppendRow. It then matches the map keys to the respective columns and appends the values. It should also be possible to omit specific columns or auto-cast if the value type in the map does not perfectly align with the table's column type.

@taniabogatsch
Copy link
Collaborator

make a slice of driver.Value to pass to AppendRow

This should already be possible to implement, as AppendRow calls into appendRowSlice, which we could expose. 🤔

// AppendRow loads a row of values into the appender. The values are provided as separate arguments.
func (a *Appender) AppendRow(args ...driver.Value) error {
	// ...
	err := a.appendRowSlice(args)
	// ...
}

// ...

func (a *Appender) appendRowSlice(args []driver.Value) error {
// ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature [feature] request or PR requires latest duckdb
Projects
None yet
Development

No branches or pull requests

2 participants