Jefffrey opened a new issue, #19436:
URL: https://github.com/apache/datafusion/issues/19436

   ### Is your feature request related to a problem or challenge?
   
   Some of the APIs for `ScalarValue` are confusing in which operations are 
permitted. For example:
   
   
https://github.com/apache/datafusion/blob/5419ff5902dfb7a9a1099022fefe289bd5de71ec/datafusion/common/src/scalar/mod.rs#L1446-L1452
   
   If the data type doesn't support the concept of a zero value, we return an 
error. Ideally callers would check for this error, but usually we just bubble 
any errors up with `?`. Perhaps we should consider changing the return to be an 
`Option` so the caller can match on whether the given datatype has a zero value 
or not, instead of resorting to using `Result` to represent this?
   
   Another example:
   
   
https://github.com/apache/datafusion/blob/5419ff5902dfb7a9a1099022fefe289bd5de71ec/datafusion/common/src/scalar/mod.rs#L1798-L1801
   
   Here, for decimals we can't actually represent a value of ten if we have 
negative scale less than -1; so we return an internal error in that case, but 
that means callers need to either prevent calling this function with a negative 
scale decimal (that isn't -1) or match on the result. If we encode it as 
`Result<Option<_>>` instead, with the `Result` reserved for returning errors in 
case of unusual behaviour (e.g. invalid precision/scale combination), it can 
make it more clear that sometimes the value of ten just doesn't exist.
   
   ### Describe the solution you'd like
   
   _No response_
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to