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
Precision not respected for decimals in struct #253
Hi! I am using the databricks-sql-go library in my application and seeing this weird behaviour when querying decimal columns. I am using CAST(... AS DECIMAL(5, 2)) to get my desired precision and it works for DECIMAL columns but when I do the same for values inside structs, the precision does not apply.
For example in this sql
SELECT'1'AS id,
19.99as test_decimal,
named_struct('col1', 'Field1', 'col2', 19.99) as arr,
CAST(19.99ASDECIMAL(5, 2)) as test_decimal2,
named_struct('col1', 'Field1', 'col2', CAST(19.99ASDECIMAL(5, 2))) as arr2;
Heres a look at the sql row in debug mode Note that the decimal value in both structs is 19.990000000000002
With this sql I am querying the decimal value of 19.99 in different ways and I was expecting CAST(19.99 AS DECIMAL(5, 2) to be respected but instead I still get 19.990000000000002
Is there a better way to do this? Is this an issue with the driver and are there any plans to fix this on the driver side?
Reacted by Vikrant Puppala and James Vorderbruggen
Interesting. I was able to reproduce with the following code:
package main
import (
"context""database/sql""fmt"
_ "github.com/databricks/databricks-sql-go"
)
funcmain() {
db, err:=sql.Open("databricks", "token:*****@*****:443/sql/1.0/warehouses/*****")
iferr!=nil {
panic(err)
}
deferdb.Close()
row:=db.QueryRowContext(context.Background(), `SELECT '1' AS id, 19.99 as test_decimal, named_struct('col1', 'Field1', 'col2', 19.99) as arr, CAST(19.99 AS DECIMAL(5, 2)) as test_decimal2, named_struct('col1', 'Field1', 'col2', CAST(19.99 AS DECIMAL(5, 2))) as arr2;`)
varidstringvartestDecimalfloat64vararranyvartestDecimal2float64vararr2anyerr=row.Scan(&id, &testDecimal, &arr, &testDecimal2, &arr2)
iferr!=nil {
panic(err)
}
// Set a breakpoint on the next line to inspect variables in your debuggerfmt.Println(id, testDecimal, arr, testDecimal2, arr2)
}
Activity
JamesVorder commentedon Dec 16, 2025
Interesting. I was able to reproduce with the following code:
Prepare for v1.14.0 release (#398)
chore(go): bump github.com/databricks/databricks-sql-go from 1.9.0 to…