Skip to content

Commit

Permalink
Add destroy data_chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
maiadegraaf committed Dec 22, 2023
1 parent 03f768b commit c8fd7c8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions appender.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,18 @@ func (a *Appender) Error() error {

// Flush the appender to the underlying table and clear the internal cache.
func (a *Appender) Flush() error {
// set the size of the current chunk to the current row
C.duckdb_data_chunk_set_size(a.chunks[a.currentChunkIdx], C.uint64_t(a.currentRow))

// append all chunks to the appender and destroy them
var rv C.duckdb_state
for i, chunk := range a.chunks {
rv = C.duckdb_append_data_chunk(*a.appender, chunk)
if rv == C.DuckDBError {
dbErr := C.GoString(C.duckdb_appender_error(*a.appender))
return fmt.Errorf("duckdb error appending chunk %d of %d: %s", i+1, a.currentChunkIdx+1, dbErr)
}
C.duckdb_destroy_data_chunk(&chunk)
}

if state := C.duckdb_appender_flush(*a.appender); state == C.DuckDBError {
Expand Down

0 comments on commit c8fd7c8

Please sign in to comment.