[jira] [Commented] (CALCITE-6259) Using log10 and log functions with arguments 0

2024-02-11 Thread Caican Cai (Jira)


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

Caican Cai commented on CALCITE-6259:
-

Do we need to modify log function in calcite.

 

According to my observation, the log function of any sql dialect will follow 
this set of sqlfunctions logic
{code:java}
/** SQL {@code LOG(number, number2)} function applied to double values. */
public static double log(double d0, double d1) {
  return Math.log(d0) / Math.log(d1);
}

/** SQL {@code LOG(number, number2)} function applied to
 * double and BigDecimal values. */
public static double log(double d0, BigDecimal d1) {
  return Math.log(d0) / Math.log(d1.doubleValue());
}

/** SQL {@code LOG(number, number2)} function applied to
 * BigDecimal and double values. */
public static double log(BigDecimal d0, double d1) {
  return Math.log(d0.doubleValue()) / Math.log(d1);
}

/** SQL {@code LOG(number, number2)} function applied to double values. */
public static double log(BigDecimal d0, BigDecimal d1) {
  return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue());
} {code}

> Using log10 and log functions with arguments 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
>
>
> When log10(0) returns null in mysql and spark, but log10 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)


[jira] [Commented] (CALCITE-6259) Using log10 and log functions with arguments 0

2024-02-11 Thread Caican Cai (Jira)


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

Caican Cai commented on CALCITE-6259:
-

Mysql and spark the results are shown in attachment or 
https://github.com/apache/calcite/pull/3648

> Using log10 and log functions with arguments 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
>
>
> When log10(0) returns null in mysql and spark, but log10 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)