uber / athenadriver

A fully-featured AWS Athena database driver (+ athenareader https://github.com/uber/athenadriver/tree/master/athenareader)
https://uber.github.io/athenadriver
MIT License
148 stars 33 forks source link

Allow returning nil for missing values #51

Closed kevinwcyu closed 6 months ago

kevinwcyu commented 1 year ago

Currently missing values return an empty string or default zero value https://github.com/uber/athenadriver#missing-value-handling, or an error is raised.

Can an additional configuration option be set to allow the user to allow nil values? Something like Config.SetMissingAsNil(true)? And add IsMissingAsNil() here: https://github.com/uber/athenadriver/blob/7f6d139d7c52e8502338c79a5dd4b46b2b5fadde/go/config.go#L301-L308

It can be checked here and return nil, nil if driverConfig.IsMissingAsNil() is true: https://github.com/uber/athenadriver/blob/7f6d139d7c52e8502338c79a5dd4b46b2b5fadde/go/rows.go#L275

With the current options we run into errors or undesirable behaviour. In the case where we set missing values to return a default value, it's not clear to the end user whether a value was missing or if it's actually the default value. This is undesirable because the end user can't differentiate between real data and missing data. In the other case where an empty string is returned, when we Scan the Rows returned we hit a conversion error https://cs.opensource.google/go/go/+/refs/tags/go1.20.4:src/database/sql/sql.go;l=3253 if the type of the column isn't a string.

henrywoo commented 6 months ago

Fixed at https://github.com/uber/athenadriver/pull/52