This is an automated email from the ASF dual-hosted git repository.

mmior pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/master by this push:
     new cce9c79  [CALCITE-2750] PI operator incorrectly identified as dynamic 
function
cce9c79 is described below

commit cce9c79ac3cc40988e342ace5340b5ed771bc2a2
Author: Juhwan Kim <[email protected]>
AuthorDate: Fri Dec 21 18:36:07 2018 -0800

    [CALCITE-2750] PI operator incorrectly identified as dynamic function
    
    Change-Id: I32d931ce22d430d466ddcd8fff6f944eee7cdfc1
    
    [CALCITE-2750] Add a test to ensure that PI function is not dynamic
    
    Change-Id: I9e50b7f75a66bd83904ed771765afda2381c413c
    
    [CALCITE-2750] Add error message in the test
    
    Change-Id: Id7cca495e14bd15a6ac70de904c6329ab60e3682
    
    [CALCITE-2750] Fix checkstyle error
    
    Change-Id: I5a8153e9fedb1a166d8716e45f47f3cd3cc8af58
---
 .../org/apache/calcite/sql/fun/SqlBaseContextVariable.java |  3 +--
 .../org/apache/calcite/sql/fun/SqlStdOperatorTable.java    | 14 ++++++++++++--
 .../org/apache/calcite/sql/test/SqlOperatorBaseTest.java   |  6 ++++++
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlBaseContextVariable.java 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlBaseContextVariable.java
index b12f19c..ba4497f 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlBaseContextVariable.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlBaseContextVariable.java
@@ -26,8 +26,7 @@ import org.apache.calcite.sql.type.SqlReturnTypeInference;
 import org.apache.calcite.sql.validate.SqlMonotonicity;
 
 /**
- * Base class for functions such as "PI", "USER", "CURRENT_ROLE", and
- * "CURRENT_PATH".
+ * Base class for functions such as "USER", "CURRENT_ROLE", and "CURRENT_PATH".
  */
 public class SqlBaseContextVariable extends SqlFunction {
   //~ Constructors -----------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
index 3990012..754f9c3 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
@@ -43,6 +43,7 @@ import org.apache.calcite.sql.SqlRankFunction;
 import org.apache.calcite.sql.SqlSampleSpec;
 import org.apache.calcite.sql.SqlSetOperator;
 import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlSyntax;
 import org.apache.calcite.sql.SqlUnnestOperator;
 import org.apache.calcite.sql.SqlUtil;
 import org.apache.calcite.sql.SqlValuesOperator;
@@ -1672,8 +1673,17 @@ public class SqlStdOperatorTable extends 
ReflectiveSqlOperatorTable {
           SqlFunctionCategory.NUMERIC);
 
   public static final SqlFunction PI =
-      new SqlBaseContextVariable("PI", ReturnTypes.DOUBLE,
-          SqlFunctionCategory.NUMERIC);
+      new SqlFunction(
+          "PI",
+          SqlKind.OTHER_FUNCTION,
+          ReturnTypes.DOUBLE,
+          null,
+          OperandTypes.NILADIC,
+          SqlFunctionCategory.NUMERIC) {
+        public SqlSyntax getSyntax() {
+          return SqlSyntax.FUNCTION_ID;
+        }
+      };
 
   /** {@code FIRST} function to be used within {@code MATCH_RECOGNIZE}. */
   public static final SqlFunction FIRST =
diff --git 
a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java 
b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
index 46b78f1..9773b1e 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
@@ -5031,6 +5031,12 @@ public abstract class SqlOperatorBaseTest {
     tester.checkScalarApprox("PI", "DOUBLE NOT NULL", 3.1415d, 0.0001d);
     tester.checkFails("^PI()^",
         "No match found for function signature PI\\(\\)", false);
+
+    // assert that PI function is not dynamic [CALCITE-2750]
+    assertEquals(
+        "PI operator should not be identified as dynamic function",
+        SqlStdOperatorTable.PI.isDynamicFunction(),
+        false);
   }
 
   @Test public void testRadiansFunc() {

Reply via email to