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 2014/10/01 20:39:41 UTC

[1/2] git commit: Covariance function - allow 2 arguments

Repository: incubator-optiq
Updated Branches:
  refs/heads/master 7fc4f6e08 -> af86cd87a


Covariance function - allow 2 arguments


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

Branch: refs/heads/master
Commit: d4ab395c3ee346a4d40a44fcb949eab2d5d11171
Parents: 7fc4f6e
Author: Yash Sharma <ya...@snapdeal.com>
Authored: Sun Sep 28 18:15:15 2014 +0530
Committer: Julian Hyde <jh...@apache.org>
Committed: Wed Oct 1 00:39:18 2014 -0700

----------------------------------------------------------------------
 .../eigenbase/sql/fun/SqlAvgAggFunction.java    |  2 -
 .../eigenbase/sql/fun/SqlCovarAggFunction.java  | 93 ++++++++++++++++++++
 .../eigenbase/sql/fun/SqlStdOperatorTable.java  |  4 +-
 .../sql2rel/StandardConvertletTable.java        |  6 --
 .../eigenbase/sql/test/SqlOperatorBaseTest.java | 16 ++--
 5 files changed, 103 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/d4ab395c/core/src/main/java/org/eigenbase/sql/fun/SqlAvgAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/sql/fun/SqlAvgAggFunction.java b/core/src/main/java/org/eigenbase/sql/fun/SqlAvgAggFunction.java
index 05f9636..8a6bfe7 100644
--- a/core/src/main/java/org/eigenbase/sql/fun/SqlAvgAggFunction.java
+++ b/core/src/main/java/org/eigenbase/sql/fun/SqlAvgAggFunction.java
@@ -79,8 +79,6 @@ public class SqlAvgAggFunction extends SqlAggFunction {
 
   public enum Subtype {
     AVG,
-    COVAR_POP,
-    COVAR_SAMP,
     STDDEV_POP,
     STDDEV_SAMP,
     VAR_POP,

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/d4ab395c/core/src/main/java/org/eigenbase/sql/fun/SqlCovarAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/sql/fun/SqlCovarAggFunction.java b/core/src/main/java/org/eigenbase/sql/fun/SqlCovarAggFunction.java
new file mode 100644
index 0000000..77d7dbf
--- /dev/null
+++ b/core/src/main/java/org/eigenbase/sql/fun/SqlCovarAggFunction.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.eigenbase.sql.fun;
+
+import java.util.List;
+
+import com.google.common.collect.ImmutableList;
+import org.eigenbase.reltype.RelDataType;
+import org.eigenbase.reltype.RelDataTypeFactory;
+import org.eigenbase.sql.SqlAggFunction;
+import org.eigenbase.sql.SqlFunctionCategory;
+import org.eigenbase.sql.SqlKind;
+import org.eigenbase.sql.type.OperandTypes;
+import org.eigenbase.sql.type.ReturnTypes;
+
+
+/**
+ * <code>Covar</code> is an aggregator which returns the Covariance of the
+ * values which go into it. It has precisely two arguments of numeric type
+ * (<code>int</code>, <code>long</code>, <code>float</code>, <code>
+ * double</code>), and the result is the same type.
+ */
+public class SqlCovarAggFunction extends SqlAggFunction {
+  //~ Instance fields --------------------------------------------------------
+
+  private final RelDataType type;
+  private final Subtype subtype;
+
+  //~ Constructors -----------------------------------------------------------
+
+  /**
+   * Creates a SqlAvgAggFunction
+   *
+   * @param type    Data type
+   * @param subtype Specific function, e.g. AVG or STDDEV_POP
+   */
+  public SqlCovarAggFunction(
+          RelDataType type,
+          Subtype subtype) {
+    super(
+        subtype.name(),
+        SqlKind.OTHER_FUNCTION,
+        ReturnTypes.ARG0_NULLABLE_IF_EMPTY,
+        null,
+        OperandTypes.NUMERIC_NUMERIC,
+        SqlFunctionCategory.NUMERIC);
+    this.type = type;
+    this.subtype = subtype;
+  }
+
+  //~ Methods ----------------------------------------------------------------
+
+  public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
+    return ImmutableList.of(type);
+  }
+
+  public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
+    return type;
+  }
+
+  /**
+   * Returns the specific function, e.g. COVAR_POP or COVAR_SAMP.
+   *
+   * @return Subtype
+   */
+  public Subtype getSubtype() {
+    return subtype;
+  }
+
+/**
+ * Enum for defining specific types.
+ */
+  public enum Subtype {
+    COVAR_POP,
+    COVAR_SAMP
+  }
+}
+
+// End SqlCovarAggFunction.java

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/d4ab395c/core/src/main/java/org/eigenbase/sql/fun/SqlStdOperatorTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/sql/fun/SqlStdOperatorTable.java b/core/src/main/java/org/eigenbase/sql/fun/SqlStdOperatorTable.java
index c4e871c..e46cc3f 100644
--- a/core/src/main/java/org/eigenbase/sql/fun/SqlStdOperatorTable.java
+++ b/core/src/main/java/org/eigenbase/sql/fun/SqlStdOperatorTable.java
@@ -675,13 +675,13 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable {
    * <code>COVAR_POP</code> aggregate function.
    */
   public static final SqlAggFunction COVAR_POP =
-      new SqlAvgAggFunction(null, SqlAvgAggFunction.Subtype.COVAR_POP);
+      new SqlCovarAggFunction(null, SqlCovarAggFunction.Subtype.COVAR_POP);
 
   /**
    * <code>COVAR_SAMP</code> aggregate function.
    */
   public static final SqlAggFunction COVAR_SAMP =
-      new SqlAvgAggFunction(null, SqlAvgAggFunction.Subtype.COVAR_SAMP);
+      new SqlCovarAggFunction(null, SqlCovarAggFunction.Subtype.COVAR_SAMP);
 
   /**
    * <code>STDDEV_SAMP</code> aggregate function.

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/d4ab395c/core/src/main/java/org/eigenbase/sql2rel/StandardConvertletTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/sql2rel/StandardConvertletTable.java b/core/src/main/java/org/eigenbase/sql2rel/StandardConvertletTable.java
index 7e23f93..59b48d7 100644
--- a/core/src/main/java/org/eigenbase/sql2rel/StandardConvertletTable.java
+++ b/core/src/main/java/org/eigenbase/sql2rel/StandardConvertletTable.java
@@ -173,12 +173,6 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
         SqlStdOperatorTable.AVG,
         new AvgVarianceConvertlet(SqlAvgAggFunction.Subtype.AVG));
     registerOp(
-        SqlStdOperatorTable.COVAR_POP,
-        new AvgVarianceConvertlet(SqlAvgAggFunction.Subtype.COVAR_POP));
-    registerOp(
-        SqlStdOperatorTable.COVAR_SAMP,
-        new AvgVarianceConvertlet(SqlAvgAggFunction.Subtype.COVAR_SAMP));
-    registerOp(
         SqlStdOperatorTable.STDDEV_POP,
         new AvgVarianceConvertlet(SqlAvgAggFunction.Subtype.STDDEV_POP));
     registerOp(

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/d4ab395c/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java b/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java
index b1118b2..c04bec2 100644
--- a/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java
+++ b/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java
@@ -4484,11 +4484,11 @@ public abstract class SqlOperatorBaseTest {
         "Unknown identifier '\\*'",
         false);
     tester.checkFails(
-        "^covar_pop(cast(null as varchar(2)))^",
-        "(?s)Cannot apply 'COVAR_POP' to arguments of type 'COVAR_POP\\(<VARCHAR\\(2\\)>\\)'\\. Supported form\\(s\\): 'COVAR_POP\\(<NUMERIC>\\)'.*",
+        "^covar_pop(cast(null as varchar(2)),cast(null as varchar(2)))^",
+        "(?s)Cannot apply 'COVAR_POP' to arguments of type 'COVAR_POP\\(<VARCHAR\\(2\\)>, <VARCHAR\\(2\\)>\\)'\\. Supported form\\(s\\): 'COVAR_POP\\(<NUMERIC>, <NUMERIC>\\)'.*",
         false);
-    tester.checkType("covar_pop(CAST(NULL AS INTEGER))", "INTEGER");
-    checkAggType(tester, "covar_pop(DISTINCT 1.5)", "DECIMAL(2, 1) NOT NULL");
+    tester.checkType("covar_pop(CAST(NULL AS INTEGER),CAST(NULL AS INTEGER))", "INTEGER");
+    checkAggType(tester, "covar_pop(1.5, 2.5)", "DECIMAL(2, 1) NOT NULL");
     if (!enable) {
       return;
     }
@@ -4507,11 +4507,11 @@ public abstract class SqlOperatorBaseTest {
         "Unknown identifier '\\*'",
         false);
     tester.checkFails(
-        "^covar_samp(cast(null as varchar(2)))^",
-        "(?s)Cannot apply 'COVAR_SAMP' to arguments of type 'COVAR_SAMP\\(<VARCHAR\\(2\\)>\\)'\\. Supported form\\(s\\): 'COVAR_SAMP\\(<NUMERIC>\\)'.*",
+        "^covar_samp(cast(null as varchar(2)),cast(null as varchar(2)))^",
+        "(?s)Cannot apply 'COVAR_SAMP' to arguments of type 'COVAR_SAMP\\(<VARCHAR\\(2\\)>, <VARCHAR\\(2\\)>\\)'\\. Supported form\\(s\\): 'COVAR_SAMP\\(<NUMERIC>, <NUMERIC>\\)'.*",
         false);
-    tester.checkType("covar_samp(CAST(NULL AS INTEGER))", "INTEGER");
-    checkAggType(tester, "covar_samp(DISTINCT 1.5)", "DECIMAL(2, 1) NOT NULL");
+    tester.checkType("covar_samp(CAST(NULL AS INTEGER),CAST(NULL AS INTEGER))", "INTEGER");
+    checkAggType(tester, "covar_samp(1.5, 2.5)", "DECIMAL(2, 1) NOT NULL");
     if (!enable) {
       return;
     }


[2/2] git commit: [OPTIQ-422] Add REGR_SXX and REGR_SYY regression functions

Posted by jh...@apache.org.
[OPTIQ-422] Add REGR_SXX and REGR_SYY regression functions


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

Branch: refs/heads/master
Commit: af86cd87a8c129867d49d87c15d62896a56f9108
Parents: d4ab395
Author: Yash Sharma <ya...@snapdeal.com>
Authored: Sun Sep 28 19:45:24 2014 +0530
Committer: Julian Hyde <jh...@apache.org>
Committed: Wed Oct 1 00:55:16 2014 -0700

----------------------------------------------------------------------
 .../main/codegen/templates/CombinedParser.jj    |  3 ++
 .../eigenbase/sql/fun/SqlCovarAggFunction.java  | 23 ++++-----
 .../eigenbase/sql/fun/SqlStdOperatorTable.java  | 18 +++++--
 .../org/eigenbase/sql/test/SqlAdvisorTest.java  |  2 +
 .../eigenbase/sql/test/SqlOperatorBaseTest.java | 54 +++++++++++++++++++-
 5 files changed, 83 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/af86cd87/core/src/main/codegen/templates/CombinedParser.jj
----------------------------------------------------------------------
diff --git a/core/src/main/codegen/templates/CombinedParser.jj b/core/src/main/codegen/templates/CombinedParser.jj
index b5dff64..54b6df2 100644
--- a/core/src/main/codegen/templates/CombinedParser.jj
+++ b/core/src/main/codegen/templates/CombinedParser.jj
@@ -4129,6 +4129,8 @@ SqlIdentifier ReservedFunctionName() :
         | <PERCENT_RANK>
         | <POWER>
         | <RANK>
+        | <REGR_SXX>
+        | <REGR_SYY>
         | <ROW_NUMBER>
         | <SQRT>
         | <STDDEV_POP>
@@ -4741,6 +4743,7 @@ SqlPostfixOperator PostfixRowOperator() :
     | < REGR_SLOPE: "REGR_SLOPE" >
     | < REGR_SXX: "REGR_SXX" >
     | < REGR_SXY: "REGR_SXY" >
+    | < REGR_SYY: "REGR_SYY" >
     | < RELATIVE: "RELATIVE" >
     | < RELEASE: "RELEASE" >
     | < REPEATABLE: "REPEATABLE" >

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/af86cd87/core/src/main/java/org/eigenbase/sql/fun/SqlCovarAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/sql/fun/SqlCovarAggFunction.java b/core/src/main/java/org/eigenbase/sql/fun/SqlCovarAggFunction.java
index 77d7dbf..f759d0c 100644
--- a/core/src/main/java/org/eigenbase/sql/fun/SqlCovarAggFunction.java
+++ b/core/src/main/java/org/eigenbase/sql/fun/SqlCovarAggFunction.java
@@ -18,7 +18,6 @@ package org.eigenbase.sql.fun;
 
 import java.util.List;
 
-import com.google.common.collect.ImmutableList;
 import org.eigenbase.reltype.RelDataType;
 import org.eigenbase.reltype.RelDataTypeFactory;
 import org.eigenbase.sql.SqlAggFunction;
@@ -27,6 +26,7 @@ import org.eigenbase.sql.SqlKind;
 import org.eigenbase.sql.type.OperandTypes;
 import org.eigenbase.sql.type.ReturnTypes;
 
+import com.google.common.collect.ImmutableList;
 
 /**
  * <code>Covar</code> is an aggregator which returns the Covariance of the
@@ -43,16 +43,13 @@ public class SqlCovarAggFunction extends SqlAggFunction {
   //~ Constructors -----------------------------------------------------------
 
   /**
-   * Creates a SqlAvgAggFunction
+   * Creates a SqlCovarAggFunction.
    *
    * @param type    Data type
-   * @param subtype Specific function, e.g. AVG or STDDEV_POP
+   * @param subtype Specific function, e.g. COVAR_POP
    */
-  public SqlCovarAggFunction(
-          RelDataType type,
-          Subtype subtype) {
-    super(
-        subtype.name(),
+  public SqlCovarAggFunction(RelDataType type, Subtype subtype) {
+    super(subtype.name(),
         SqlKind.OTHER_FUNCTION,
         ReturnTypes.ARG0_NULLABLE_IF_EMPTY,
         null,
@@ -81,12 +78,14 @@ public class SqlCovarAggFunction extends SqlAggFunction {
     return subtype;
   }
 
-/**
- * Enum for defining specific types.
- */
+  /**
+   * Enum for defining specific types.
+   */
   public enum Subtype {
     COVAR_POP,
-    COVAR_SAMP
+    COVAR_SAMP,
+    REGR_SXX,
+    REGR_SYY
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/af86cd87/core/src/main/java/org/eigenbase/sql/fun/SqlStdOperatorTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/sql/fun/SqlStdOperatorTable.java b/core/src/main/java/org/eigenbase/sql/fun/SqlStdOperatorTable.java
index e46cc3f..7f7bf73 100644
--- a/core/src/main/java/org/eigenbase/sql/fun/SqlStdOperatorTable.java
+++ b/core/src/main/java/org/eigenbase/sql/fun/SqlStdOperatorTable.java
@@ -672,6 +672,18 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable {
       new SqlAvgAggFunction(null, SqlAvgAggFunction.Subtype.STDDEV_POP);
 
   /**
+   * <code>REGR_SXX</code> aggregate function.
+   */
+  public static final SqlAggFunction REGR_SXX =
+      new SqlCovarAggFunction(null, SqlCovarAggFunction.Subtype.REGR_SXX);
+
+  /**
+   * <code>REGR_SYY</code> aggregate function.
+   */
+  public static final SqlAggFunction REGR_SYY =
+      new SqlCovarAggFunction(null, SqlCovarAggFunction.Subtype.REGR_SYY);
+
+  /**
    * <code>COVAR_POP</code> aggregate function.
    */
   public static final SqlAggFunction COVAR_POP =
@@ -705,7 +717,7 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable {
   // WINDOW Aggregate Functions
   //-------------------------------------------------------------
   /**
-   * <code>HISTORAM</code> aggregate function support. Used by window
+   * <code>HISTOGRAM</code> aggregate function support. Used by window
    * aggregate versions of MIN/MAX
    */
   public static final SqlAggFunction HISTOGRAM_AGG =
@@ -880,8 +892,8 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable {
    * function into a relation, e.g. "<code>SELECT * FROM
    * TABLE(ramp(5))</code>".
    *
-   * <p>This operator has function syntax (with one argument), whereas {@link
-   * #EXPLICIT_TABLE} is a prefix operator.
+   * <p>This operator has function syntax (with one argument), whereas
+   * {@link #EXPLICIT_TABLE} is a prefix operator.
    */
   public static final SqlSpecialOperator COLLECTION_TABLE =
       new SqlCollectionTableOperator(

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/af86cd87/core/src/test/java/org/eigenbase/sql/test/SqlAdvisorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/eigenbase/sql/test/SqlAdvisorTest.java b/core/src/test/java/org/eigenbase/sql/test/SqlAdvisorTest.java
index f9ad12e..d8ebe27 100644
--- a/core/src/test/java/org/eigenbase/sql/test/SqlAdvisorTest.java
+++ b/core/src/test/java/org/eigenbase/sql/test/SqlAdvisorTest.java
@@ -151,6 +151,8 @@ public class SqlAdvisorTest extends SqlValidatorTestCase {
           "KEYWORD(POSITION)",
           "KEYWORD(POWER)",
           "KEYWORD(RANK)",
+          "KEYWORD(REGR_SXX)",
+          "KEYWORD(REGR_SYY)",
           "KEYWORD(ROW)",
           "KEYWORD(ROW_NUMBER)",
           "KEYWORD(SESSION_USER)",

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/af86cd87/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java b/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java
index c04bec2..a51bc9b 100644
--- a/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java
+++ b/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java
@@ -4487,7 +4487,8 @@ public abstract class SqlOperatorBaseTest {
         "^covar_pop(cast(null as varchar(2)),cast(null as varchar(2)))^",
         "(?s)Cannot apply 'COVAR_POP' to arguments of type 'COVAR_POP\\(<VARCHAR\\(2\\)>, <VARCHAR\\(2\\)>\\)'\\. Supported form\\(s\\): 'COVAR_POP\\(<NUMERIC>, <NUMERIC>\\)'.*",
         false);
-    tester.checkType("covar_pop(CAST(NULL AS INTEGER),CAST(NULL AS INTEGER))", "INTEGER");
+    tester.checkType("covar_pop(CAST(NULL AS INTEGER),CAST(NULL AS INTEGER))",
+        "INTEGER");
     checkAggType(tester, "covar_pop(1.5, 2.5)", "DECIMAL(2, 1) NOT NULL");
     if (!enable) {
       return;
@@ -4510,7 +4511,8 @@ public abstract class SqlOperatorBaseTest {
         "^covar_samp(cast(null as varchar(2)),cast(null as varchar(2)))^",
         "(?s)Cannot apply 'COVAR_SAMP' to arguments of type 'COVAR_SAMP\\(<VARCHAR\\(2\\)>, <VARCHAR\\(2\\)>\\)'\\. Supported form\\(s\\): 'COVAR_SAMP\\(<NUMERIC>, <NUMERIC>\\)'.*",
         false);
-    tester.checkType("covar_samp(CAST(NULL AS INTEGER),CAST(NULL AS INTEGER))", "INTEGER");
+    tester.checkType("covar_samp(CAST(NULL AS INTEGER),CAST(NULL AS INTEGER))",
+        "INTEGER");
     checkAggType(tester, "covar_samp(1.5, 2.5)", "DECIMAL(2, 1) NOT NULL");
     if (!enable) {
       return;
@@ -4523,6 +4525,54 @@ public abstract class SqlOperatorBaseTest {
         0d);
   }
 
+  @Test public void testRegrSxxFunc() {
+    tester.setFor(SqlStdOperatorTable.REGR_SXX, VM_EXPAND);
+    tester.checkFails(
+        "regr_sxx(^*^)",
+        "Unknown identifier '\\*'",
+        false);
+    tester.checkFails(
+        "^regr_sxx(cast(null as varchar(2)), cast(null as varchar(2)))^",
+        "(?s)Cannot apply 'REGR_SXX' to arguments of type 'REGR_SXX\\(<VARCHAR\\(2\\)>, <VARCHAR\\(2\\)>\\)'\\. Supported form\\(s\\): 'REGR_SXX\\(<NUMERIC>, <NUMERIC>\\)'.*",
+        false);
+    tester.checkType("regr_sxx(CAST(NULL AS INTEGER), CAST(NULL AS INTEGER))",
+        "INTEGER");
+    checkAggType(tester, "regr_sxx(1.5, 2.5)", "DECIMAL(2, 1) NOT NULL");
+    if (!enable) {
+      return;
+    }
+    // with zero values
+    tester.checkAgg(
+        "regr_sxx(x)",
+        new String[]{},
+        null,
+        0d);
+  }
+
+  @Test public void testRegrSyyFunc() {
+    tester.setFor(SqlStdOperatorTable.REGR_SYY, VM_EXPAND);
+    tester.checkFails(
+        "regr_syy(^*^)",
+        "Unknown identifier '\\*'",
+        false);
+    tester.checkFails(
+        "^regr_syy(cast(null as varchar(2)), cast(null as varchar(2)))^",
+        "(?s)Cannot apply 'REGR_SYY' to arguments of type 'REGR_SYY\\(<VARCHAR\\(2\\)>, <VARCHAR\\(2\\)>\\)'\\. Supported form\\(s\\): 'REGR_SYY\\(<NUMERIC>, <NUMERIC>\\)'.*",
+        false);
+    tester.checkType("regr_syy(CAST(NULL AS INTEGER), CAST(NULL AS INTEGER))",
+        "INTEGER");
+    checkAggType(tester, "regr_syy(1.5, 2.5)", "DECIMAL(2, 1) NOT NULL");
+    if (!enable) {
+      return;
+    }
+    // with zero values
+    tester.checkAgg(
+        "regr_syy(x)",
+        new String[]{},
+        null,
+        0d);
+  }
+
   @Test public void testStddevPopFunc() {
     tester.setFor(SqlStdOperatorTable.STDDEV_POP, VM_EXPAND);
     tester.checkFails(