[
https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816776#comment-17816776
]
Julian Hyde commented on CALCITE-6259:
--------------------------------------
1. Whatever behavior we choose, let's make sure the {{LOG}}, {{LOG10}} and
{{LOG2}} are consistent with each other. (For example, I don't know whether
Postgres has a {{LOG2}} function, but regardless, the {{LOG2(0)}} in Postgres
mode should return the same as {{LOG(0)}}.)
2. We should also check the behavior of negative values. (-Infinity is a
plausible value for {{log(0)}}, mathematically speaking, but log of a negative
number is imaginary.)
3. I would support making the functions behave differently depending on which
database we are trying to emulate.
Regarding how we could implement 3. In CALCITE-4427 we gave the {{SUBSTRING}}
operator different semantics depending on the {{SqlConformance.semantics()}}
method. Unlike that case, we don't need separate {{LOGxx}} operators or methods
in {{SqlFunctions}} for each dialect; it would be sufficient to add an enum
argument to the method.
> Return the result with the log10 and log functions of argument 0
> ----------------------------------------------------------------
>
> Key: CALCITE-6259
> URL: https://issues.apache.org/jira/browse/CALCITE-6259
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.36.0
> Reporter: Caican Cai
> Priority: Major
> Fix For: 1.37.0
>
> Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png,
> 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png,
> image-2024-02-12-21-52-45-462.png
>
>
> When log10(0) returns null in mysql and spark, but log10(0) returns error in
> postgres, neither is calcite's -Intity
> {code:java}
> postgres=# select log10(0);
> ERROR: cannot take logarithm of zero
> postgres=# select log(2,0);
> ERROR: cannot take logarithm of zero
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)