You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error while scanning column of type array<decimal(10,2)> into Go type []float64 #213
I have a table that has a column AMOUNTS with a type array<decimal(10,2)>, which I expect to scan into a field type []float64.
This is the test I wrote to reproduce it:
func (s*DatabricksRepositorySuite) Test_Float64_Conversion() {
query:=`SELECT AMOUNTS FROM components WHERE AMOUNTS IS NOT NULL AND array_size(AMOUNTS) > 0 LIMIT 1`varresult []float64err:=s.repository.db.QueryRow(query).Scan(&result)
s.NoError(err)
}
When I run my query, I get this error:
sql: Scan error on column index 0, name "AMOUNTS": unsupported Scan, storing driver.Value type string into type *[]float64
Source
This error comes from the standard library in Go: the value for that field is provided by the SDK as a string, but the destination is []float64, so it fails. I also dove into Databricks' SDK source code and found the place [2] where the string is generated.
Closing with two ways to read complex types that work today. Both are verified on current main with array(CAST(1.50 AS DECIMAL(10,2)), CAST(2.25 AS DECIMAL(10,2))).
Through database/sql, ARRAY, MAP and STRUCT values arrive as JSON text, so scan into a string and decode it:
A small sql.Scanner wrapper like the one in the issue does the same per column.
For native values, use the Arrow batch API (rows.Rows.GetArrowBatches, available since v1.5.0 through conn.Raw). The column arrives as an Arrow list<decimal(10,2)> with exact decimal values, so no precision is lost to float64.
We're not adding native Go slices to the database/sql scan path for now.
Activity
vuanhphung commentedon Nov 20, 2026
Closing with two ways to read complex types that work today. Both are verified on current main with
array(CAST(1.50 AS DECIMAL(10,2)), CAST(2.25 AS DECIMAL(10,2))).Through
database/sql, ARRAY, MAP and STRUCT values arrive as JSON text, so scan into a string and decode it:A small
sql.Scannerwrapper like the one in the issue does the same per column.For native values, use the Arrow batch API (
rows.Rows.GetArrowBatches, available since v1.5.0 throughconn.Raw). The column arrives as an Arrowlist<decimal(10,2)>with exact decimal values, so no precision is lost to float64.We're not adding native Go slices to the
database/sqlscan path for now.