tanclary commented on PR #3252: URL: https://github.com/apache/calcite/pull/3252#issuecomment-1692153864
> I think you need more tests - one for each numeric data type. > > The implementation is actually straightforward: For INTEGER, safe_negate(x) is `x == INTEGER.MIN_VALUE ? null : -x` > > You probably don't need to add functions to `SqlFunctions`, just add logic in the implementor. Or you could just implement `SAFE_NEGATE(x)` as `SAFE_MULTIPLY(x, -1)`. > > The key thing is a comprehensive set of tests. @julianhyde I revisited this PR and made some of the changes you suggested. As far as tests go, I am not sure how to add tests for non-integer types given that the absolute value of the minimum and maximum values for other types are equivalent, so overflow, to my knowledge, is not possible. Let me know if you feel otherwise or have other comments. -- 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]
