databricks / databricks-sql-go

Golang database/sql driver for Databricks SQL.
Apache License 2.0
37 stars 41 forks source link

bug: Bad formatting for `time.Time` named arg #206

Closed candiduslynx closed 7 months ago

candiduslynx commented 7 months ago

When trying to pass an sql.NamedArg{Name: "syncTime", Value: msg.SyncTime} to ExecContext I got

[INVALID_PARAMETER_MARKER_VALUE.INVALID_VALUE_FOR_DATA_TYPE] An invalid parameter mapping was provided: the value '2024-04-10 11:44:13.011238 +0000 UTC' for parameter 'syncTime' cannot be cast to TIMESTAMP because it is malformed.

I can bypass it by using dbsql.Parameter{Name: "syncTime", Type: dbsql.SqlTimestamp, Value: msg.SyncTime.Format(time.RFC3339Nano)}, however, IMO this should be done by the SDK in here: https://github.com/databricks/databricks-sql-go/blob/00bc1c893537290e8db73b9921151123b8cebd2b/parameters.go#L134 via

param.Value = value.Format(time.RFC3339Nano)