You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Claude Brisson (Jira)" <ji...@apache.org> on 2024/10/17 04:31:00 UTC

[jira] [Commented] (CALCITE-6622) Negative logarithms should return NaN or -Inf, not throw an IllegalArgumentException

    [ https://issues.apache.org/jira/browse/CALCITE-6622?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17890315#comment-17890315 ] 

Claude Brisson commented on CALCITE-6622:
-----------------------------------------

With the new mapping of floating point rex literals as doubles, negative logarithms should in fact return {{-Inf}} (for 0) or {{Nan}} (for <0), which is what {{Math.log()}} already does. I modified the title accordingly.

I guess that the IllegalArgumentException is thrown because in 1.37 there would have been an exception at the {{BigDecimal}} contruction.

 

> Negative logarithms should return NaN or -Inf, not throw an IllegalArgumentException
> ------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6622
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6622
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.38.0
>            Reporter: Claude Brisson
>            Priority: Minor
>
> Since |CALCITE-6312], {{log}} functions in {{SqlFunctions}} do throw an {{{}IllegalArgumentException{}}}, instead as an {{ArithmeticException}} as before.
> In terms of errors categorization, it is more precise to revert to the former behavior, as {{IllegalArgumentException}} is more suited to structural errors which do not depend on the actual values, whereas we would expect negative logarithms to throw the same kind of error as an integer division by zero for instance.
> An engine implementation could choose to have a different behaviors depending on the thrown errors, for instance to just abort the constants reduction for an illegal argument versus letting the arithmetic exception propagate to alert the user.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)