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

Add generic setters to void casting values to any #276

Merged
merged 8 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions data_chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,8 @@ func (chunk *DataChunk) SetValue(colIdx int, rowIdx int, val any) error {
}
column := &chunk.columns[colIdx]

// Ensure that the types match before attempting to set anything.
// This is done to prevent failures 'halfway through' writing column values,
// potentially corrupting data in that column.
// FIXME: Can we improve efficiency here? We are casting back-and-forth to any A LOT.
// FIXME: Maybe we can make columnar insertions unsafe, i.e., we always assume a correct type.
v, err := column.tryCast(val)
if err != nil {
return addIndexToError(err, colIdx)
}

// Set the value.
column.setFn(column, C.idx_t(rowIdx), v)
return nil
return column.setFn(column, C.idx_t(rowIdx), val)
}

func (chunk *DataChunk) initFromTypes(ptr unsafe.Pointer, types []C.duckdb_logical_type, writable bool) error {
Expand Down
1 change: 1 addition & 0 deletions type_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type baseTypeInfo struct {
structEntries []StructEntry
decimalWidth uint8
decimalScale uint8
internalType Type // This is the internal type for enum and decimal values
}

type vectorTypeInfo struct {
Expand Down
Loading
Loading