You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2018/08/13 01:06:02 UTC

[2/4] calcite git commit: [CALCITE-2447] POWER, ATAN2 functions fail with NoSuchMethodException

[CALCITE-2447] POWER, ATAN2 functions fail with NoSuchMethodException

To remedy, add power, atan2 methods with arguments
"(BigDecimal b0, long b1)"  in SqlFunctions.

Close apache/calcite#777


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/ac33200f
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/ac33200f
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/ac33200f

Branch: refs/heads/master
Commit: ac33200faf62d2667c2fa075fc3423d602131d9d
Parents: eb496c7
Author: snuyanzin <sn...@gmail.com>
Authored: Fri Aug 3 19:04:19 2018 +0300
Committer: Julian Hyde <jh...@apache.org>
Committed: Fri Aug 10 10:15:32 2018 -0700

----------------------------------------------------------------------
 .../apache/calcite/runtime/SqlFunctions.java    |  9 ++++++++
 core/src/test/resources/sql/misc.iq             | 22 ++++++++++++++++++++
 2 files changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/ac33200f/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
index 83cc24e..d795102 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -830,6 +830,10 @@ public class SqlFunctions {
     return Math.pow(b0, b1.doubleValue());
   }
 
+  public static double power(BigDecimal b0, long b1) {
+    return Math.pow(b0.doubleValue(), b1);
+  }
+
   // LN
 
   /** SQL {@code LN(number)} function applied to double values. */
@@ -1115,6 +1119,11 @@ public class SqlFunctions {
     return Math.atan2(b0, b1.doubleValue());
   }
 
+  /** SQL <code>ATAN2</code> operator applied to BigDecimal/long values. */
+  public static double atan2(BigDecimal b0, long b1) {
+    return Math.atan2(b0.doubleValue(), b1);
+  }
+
   /** SQL <code>ATAN2</code> operator applied to BigDecimal values. */
   public static double atan2(BigDecimal b0, BigDecimal b1) {
     return Math.atan2(b0.doubleValue(), b1.doubleValue());

http://git-wip-us.apache.org/repos/asf/calcite/blob/ac33200f/core/src/test/resources/sql/misc.iq
----------------------------------------------------------------------
diff --git a/core/src/test/resources/sql/misc.iq b/core/src/test/resources/sql/misc.iq
index cdbde5d..2306ec7 100644
--- a/core/src/test/resources/sql/misc.iq
+++ b/core/src/test/resources/sql/misc.iq
@@ -2158,6 +2158,28 @@ where false;
 
 !ok
 
+# [CALCITE-2447] POWER, ATAN2 functions fail with NoSuchMethodException
+values power(0.5, 2);
++--------+
+| EXPR$0 |
++--------+
+|   0.25 |
++--------+
+(1 row)
+
+!ok
+
+# [CALCITE-2447] POWER, ATAN2 functions fail with NoSuchMethodException
+values atan2(0.5, 2);
++---------------------+
+| EXPR$0              |
++---------------------+
+| 0.24497866312686414 |
++---------------------+
+(1 row)
+
+!ok
+
 !set outputformat csv
 
 # [CALCITE-1167] OVERLAPS should match even if operands are in (high, low) order