beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lzljs3620...@apache.org
Subject [1/2] beam git commit: [BEAM-2563] Add integration test for math operators Misc: 1. no SQRT in Calcite, converted to POWER; 2. add DECIMAL in BeamSqlDslBase; 3. fix error in BeamSqlRoundExpression; 4. fix error in BeamSqlSignExpression;
Date Wed, 19 Jul 2017 10:55:15 GMT
Repository: beam
Updated Branches:
  refs/heads/DSL_SQL d4d615a72 -> bff21499c


[BEAM-2563] Add integration test for math operators
Misc:
1. no SQRT in Calcite, converted to POWER;
2. add DECIMAL in BeamSqlDslBase;
3. fix error in BeamSqlRoundExpression;
4. fix error in BeamSqlSignExpression;


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

Branch: refs/heads/DSL_SQL
Commit: 7f5cbbaedbbca7e1053a8458825bb0b853ca745e
Parents: d4d615a
Author: mingmxu <mingmxu@ebay.com>
Authored: Tue Jul 18 19:59:07 2017 -0700
Committer: JingsongLi <lzljs3620320@aliyun.com>
Committed: Wed Jul 19 18:52:38 2017 +0800

----------------------------------------------------------------------
 .../dsls/sql/interpreter/BeamSqlFnExecutor.java |   8 +-
 .../operator/math/BeamSqlAbsExpression.java     |   2 +-
 .../operator/math/BeamSqlAcosExpression.java    |   2 +-
 .../operator/math/BeamSqlAsinExpression.java    |   2 +-
 .../operator/math/BeamSqlAtan2Expression.java   |   3 +-
 .../operator/math/BeamSqlAtanExpression.java    |   2 +-
 .../operator/math/BeamSqlCeilExpression.java    |   3 +-
 .../operator/math/BeamSqlCosExpression.java     |   2 +-
 .../operator/math/BeamSqlCotExpression.java     |   2 +-
 .../operator/math/BeamSqlDegreesExpression.java |   2 +-
 .../operator/math/BeamSqlExpExpression.java     |   2 +-
 .../operator/math/BeamSqlFloorExpression.java   |   3 +-
 .../operator/math/BeamSqlLnExpression.java      |   2 +-
 .../operator/math/BeamSqlLogExpression.java     |   2 +-
 .../math/BeamSqlMathBinaryExpression.java       |   4 +-
 .../math/BeamSqlMathUnaryExpression.java        |   4 +-
 .../operator/math/BeamSqlPiExpression.java      |   2 +-
 .../operator/math/BeamSqlPowerExpression.java   |   3 +-
 .../operator/math/BeamSqlRadiansExpression.java |   2 +-
 .../operator/math/BeamSqlRoundExpression.java   |   6 +-
 .../operator/math/BeamSqlSignExpression.java    |  11 +-
 .../operator/math/BeamSqlSinExpression.java     |   2 +-
 .../operator/math/BeamSqlSqrtExpression.java    |  40 ---
 .../operator/math/BeamSqlTanExpression.java     |   2 +-
 .../math/BeamSqlTruncateExpression.java         |  12 +-
 .../apache/beam/dsls/sql/BeamSqlDslBase.java    |   9 +-
 .../BeamSqlMathFunctionsIntegrationTest.java    | 350 +++++++++++++++++--
 .../math/BeamSqlMathUnaryExpressionTest.java    |   6 +-
 28 files changed, 377 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/BeamSqlFnExecutor.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/BeamSqlFnExecutor.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/BeamSqlFnExecutor.java
index 0be918d..0db33cb 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/BeamSqlFnExecutor.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/BeamSqlFnExecutor.java
@@ -59,6 +59,7 @@ import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlAsinExpression;
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlAtan2Expression;
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlAtanExpression;
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlCeilExpression;
+import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlCosExpression;
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlCotExpression;
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlDegreesExpression;
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlExpExpression;
@@ -73,7 +74,6 @@ import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlRandIntegerExpr
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlRoundExpression;
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlSignExpression;
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlSinExpression;
-import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlSqrtExpression;
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlTanExpression;
 import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlTruncateExpression;
 import org.apache.beam.dsls.sql.interpreter.operator.string.BeamSqlCharLengthExpression;
@@ -247,9 +247,6 @@ public class BeamSqlFnExecutor implements BeamSqlExpressionExecutor {
         case "ABS":
           ret = new BeamSqlAbsExpression(subExps);
           break;
-        case "SQRT":
-          ret = new BeamSqlSqrtExpression(subExps);
-          break;
         case "ROUND":
           ret = new BeamSqlRoundExpression(subExps);
           break;
@@ -280,6 +277,9 @@ public class BeamSqlFnExecutor implements BeamSqlExpressionExecutor {
         case "RADIANS":
           ret = new BeamSqlRadiansExpression(subExps);
           break;
+        case "COS":
+          ret = new BeamSqlCosExpression(subExps);
+          break;
         case "SIN":
           ret = new BeamSqlSinExpression(subExps);
           break;

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAbsExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAbsExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAbsExpression.java
index 5677fc3..e563634 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAbsExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAbsExpression.java
@@ -32,7 +32,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlAbsExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlAbsExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, operands.get(0).getOutputType());
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAcosExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAcosExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAcosExpression.java
index a74ed0d..14b2a27 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAcosExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAcosExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlAcosExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlAcosExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAsinExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAsinExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAsinExpression.java
index c30d6d3..ed515b5 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAsinExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAsinExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlAsinExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlAsinExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtan2Expression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtan2Expression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtan2Expression.java
index c71ca9d..2254f99 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtan2Expression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtan2Expression.java
@@ -31,8 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlAtan2Expression extends BeamSqlMathBinaryExpression {
 
   public BeamSqlAtan2Expression(List<BeamSqlExpression> operands) {
-    super(operands);
-    this.outputType = SqlTypeName.DOUBLE;
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive<? extends Number> calculate(BeamSqlPrimitive leftOp,

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtanExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtanExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtanExpression.java
index 05c1bf6..3a14d54 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtanExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtanExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlAtanExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlAtanExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCeilExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCeilExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCeilExpression.java
index c035a75..c32c4fe 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCeilExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCeilExpression.java
@@ -31,8 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlCeilExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlCeilExpression(List<BeamSqlExpression> operands) {
-    super(operands);
-    this.outputType = SqlTypeName.DOUBLE;
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCosExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCosExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCosExpression.java
index 2e1334b..d7fdc5f 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCosExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCosExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlCosExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlCosExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCotExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCotExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCotExpression.java
index 8fd83ed..a62f756 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCotExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCotExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlCotExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlCotExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlDegreesExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlDegreesExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlDegreesExpression.java
index 2cbaf35..e440479 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlDegreesExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlDegreesExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlDegreesExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlDegreesExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlExpExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlExpExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlExpExpression.java
index d2b3497..d34726d 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlExpExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlExpExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlExpExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlExpExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlFloorExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlFloorExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlFloorExpression.java
index fe18927..47d7441 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlFloorExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlFloorExpression.java
@@ -31,8 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlFloorExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlFloorExpression(List<BeamSqlExpression> operands) {
-    super(operands);
-    this.outputType = SqlTypeName.DOUBLE;
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLnExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLnExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLnExpression.java
index a30d1ca..7cc18bf 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLnExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLnExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlLnExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlLnExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLogExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLogExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLogExpression.java
index c83f816..7253a1e 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLogExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLogExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlLogExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlLogExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathBinaryExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathBinaryExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathBinaryExpression.java
index 2d444f8..05250c0 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathBinaryExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathBinaryExpression.java
@@ -31,8 +31,8 @@ import org.apache.calcite.sql.type.SqlTypeName;
  */
 public abstract class BeamSqlMathBinaryExpression extends BeamSqlExpression {
 
-  public BeamSqlMathBinaryExpression(List<BeamSqlExpression> operands) {
-    super(operands, SqlTypeName.ANY);
+  public BeamSqlMathBinaryExpression(List<BeamSqlExpression> operands, SqlTypeName outputType) {
+    super(operands, outputType);
   }
 
   @Override public boolean accept() {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathUnaryExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathUnaryExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathUnaryExpression.java
index 4733d09..5429057 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathUnaryExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathUnaryExpression.java
@@ -32,8 +32,8 @@ import org.apache.calcite.sql.type.SqlTypeName;
  */
 public abstract class BeamSqlMathUnaryExpression extends BeamSqlExpression {
 
-  public BeamSqlMathUnaryExpression(List<BeamSqlExpression> operands) {
-    super(operands, SqlTypeName.ANY);
+  public BeamSqlMathUnaryExpression(List<BeamSqlExpression> operands, SqlTypeName outputType) {
+    super(operands, outputType);
   }
 
   @Override public boolean accept() {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlPiExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlPiExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlPiExpression.java
index 9db810e..cf797dd 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlPiExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlPiExpression.java
@@ -33,7 +33,7 @@ public class BeamSqlPiExpression extends BeamSqlExpression {
   }
 
   @Override public boolean accept() {
-    return numberOfOperands() == 0;
+    return true;
   }
 
   @Override public BeamSqlPrimitive evaluate(BeamSqlRow inputRow) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlPowerExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlPowerExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlPowerExpression.java
index d0d7298..b1a8820 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlPowerExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlPowerExpression.java
@@ -31,8 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlPowerExpression extends BeamSqlMathBinaryExpression {
 
   public BeamSqlPowerExpression(List<BeamSqlExpression> operands) {
-    super(operands);
-    this.outputType = SqlTypeName.DOUBLE;
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRadiansExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRadiansExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRadiansExpression.java
index 1ec8099..3a77634 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRadiansExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRadiansExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlRadiansExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlRadiansExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRoundExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRoundExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRoundExpression.java
index 21dc09e..a712c85 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRoundExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRoundExpression.java
@@ -33,7 +33,7 @@ public class BeamSqlRoundExpression extends BeamSqlMathBinaryExpression {
   private final BeamSqlPrimitive zero = BeamSqlPrimitive.of(SqlTypeName.INTEGER, 0);
 
   public BeamSqlRoundExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, operands.get(0).getOutputType());
     checkForSecondOperand(operands);
   }
 
@@ -67,6 +67,10 @@ public class BeamSqlRoundExpression extends BeamSqlMathBinaryExpression {
         result = BeamSqlPrimitive
             .of(SqlTypeName.DOUBLE, roundDouble(leftOp.getDouble(), toInt(rightOp.getValue())));
         break;
+      case FLOAT:
+        result = BeamSqlPrimitive.of(SqlTypeName.FLOAT,
+            (float) roundDouble(leftOp.getFloat(), toInt(rightOp.getValue())));
+        break;
       case DECIMAL:
         result = BeamSqlPrimitive.of(SqlTypeName.DECIMAL,
             roundBigDecimal(toBigDecimal(leftOp.getValue()), toInt(rightOp.getValue())));

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSignExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSignExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSignExpression.java
index 311c9a0..3f2d9af 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSignExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSignExpression.java
@@ -30,14 +30,20 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlSignExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlSignExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, operands.get(0).getOutputType());
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {
     BeamSqlPrimitive result = null;
     switch (op.getOutputType()) {
       case TINYINT:
+        result = BeamSqlPrimitive
+          .of(SqlTypeName.TINYINT, (byte) SqlFunctions.sign(SqlFunctions.toByte(op.getValue())));
+        break;
       case SMALLINT:
+        result = BeamSqlPrimitive
+          .of(SqlTypeName.SMALLINT, (short) SqlFunctions.sign(SqlFunctions.toShort(op.getValue())));
+        break;
       case INTEGER:
         result = BeamSqlPrimitive
             .of(SqlTypeName.INTEGER, SqlFunctions.sign(SqlFunctions.toInt(op.getValue())));
@@ -47,6 +53,9 @@ public class BeamSqlSignExpression extends BeamSqlMathUnaryExpression {
             .of(SqlTypeName.BIGINT, SqlFunctions.sign(SqlFunctions.toLong(op.getValue())));
         break;
       case FLOAT:
+        result = BeamSqlPrimitive
+            .of(SqlTypeName.FLOAT, (float) SqlFunctions.sign(SqlFunctions.toFloat(op.getValue())));
+        break;
       case DOUBLE:
         result = BeamSqlPrimitive
             .of(SqlTypeName.DOUBLE, SqlFunctions.sign(SqlFunctions.toDouble(op.getValue())));

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSinExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSinExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSinExpression.java
index a7efd69..3459cd3 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSinExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSinExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlSinExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlSinExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSqrtExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSqrtExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSqrtExpression.java
deleted file mode 100644
index e87ba2c..0000000
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSqrtExpression.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.apache.beam.dsls.sql.interpreter.operator.math;
-
-import java.util.List;
-import org.apache.beam.dsls.sql.interpreter.operator.BeamSqlExpression;
-import org.apache.beam.dsls.sql.interpreter.operator.BeamSqlPrimitive;
-import org.apache.calcite.sql.type.SqlTypeName;
-
-
-/**
- * {@code BeamSqlMathUnaryExpression} for 'SQRT' function.
- */
-public class BeamSqlSqrtExpression extends BeamSqlMathUnaryExpression {
-
-  public BeamSqlSqrtExpression(List<BeamSqlExpression> operands) {
-    super(operands);
-  }
-
-  @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {
-    return BeamSqlPrimitive
-        .of(SqlTypeName.DOUBLE, Math.sqrt(Double.valueOf(op.getValue().toString())));
-  }
-}

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTanExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTanExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTanExpression.java
index 4d43408..d874217 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTanExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTanExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlTanExpression extends BeamSqlMathUnaryExpression {
 
   public BeamSqlTanExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, SqlTypeName.DOUBLE);
   }
 
   @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) {

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTruncateExpression.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTruncateExpression.java b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTruncateExpression.java
index a123bf7..187f796 100644
--- a/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTruncateExpression.java
+++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTruncateExpression.java
@@ -31,7 +31,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 public class BeamSqlTruncateExpression extends BeamSqlMathBinaryExpression {
 
   public BeamSqlTruncateExpression(List<BeamSqlExpression> operands) {
-    super(operands);
+    super(operands, operands.get(0).getOutputType());
   }
 
   @Override public BeamSqlPrimitive<? extends Number> calculate(BeamSqlPrimitive leftOp,
@@ -40,7 +40,13 @@ public class BeamSqlTruncateExpression extends BeamSqlMathBinaryExpression {
     int rightIntOperand = SqlFunctions.toInt(rightOp.getValue());
     switch (leftOp.getOutputType()) {
       case SMALLINT:
+        result = BeamSqlPrimitive.of(SqlTypeName.SMALLINT,
+            (short) SqlFunctions.struncate(SqlFunctions.toInt(leftOp.getValue()), rightIntOperand));
+        break;
       case TINYINT:
+        result = BeamSqlPrimitive.of(SqlTypeName.TINYINT,
+            (byte) SqlFunctions.struncate(SqlFunctions.toInt(leftOp.getValue()), rightIntOperand));
+        break;
       case INTEGER:
         result = BeamSqlPrimitive.of(SqlTypeName.INTEGER,
             SqlFunctions.struncate(SqlFunctions.toInt(leftOp.getValue()), rightIntOperand));
@@ -50,6 +56,10 @@ public class BeamSqlTruncateExpression extends BeamSqlMathBinaryExpression {
             .of(SqlTypeName.BIGINT, SqlFunctions.struncate(leftOp.getLong(), rightIntOperand));
         break;
       case FLOAT:
+        result = BeamSqlPrimitive.of(SqlTypeName.FLOAT,
+            (float) SqlFunctions.struncate(SqlFunctions.toFloat(leftOp.getValue()),
+                rightIntOperand));
+        break;
       case DOUBLE:
         result = BeamSqlPrimitive.of(SqlTypeName.DOUBLE,
             SqlFunctions.struncate(SqlFunctions.toDouble(leftOp.getValue()), rightIntOperand));

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/test/java/org/apache/beam/dsls/sql/BeamSqlDslBase.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/test/java/org/apache/beam/dsls/sql/BeamSqlDslBase.java b/dsls/sql/src/test/java/org/apache/beam/dsls/sql/BeamSqlDslBase.java
index 24f1a0a..a5d92e7 100644
--- a/dsls/sql/src/test/java/org/apache/beam/dsls/sql/BeamSqlDslBase.java
+++ b/dsls/sql/src/test/java/org/apache/beam/dsls/sql/BeamSqlDslBase.java
@@ -17,6 +17,7 @@
  */
 package org.apache.beam.dsls.sql;
 
+import java.math.BigDecimal;
 import java.sql.Types;
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -67,9 +68,9 @@ public class BeamSqlDslBase {
   public static void prepareClass() throws ParseException {
     rowTypeInTableA = BeamSqlRowType.create(
         Arrays.asList("f_int", "f_long", "f_short", "f_byte", "f_float", "f_double", "f_string",
-            "f_timestamp", "f_int2"),
+            "f_timestamp", "f_int2", "f_decimal"),
         Arrays.asList(Types.INTEGER, Types.BIGINT, Types.SMALLINT, Types.TINYINT, Types.FLOAT,
-            Types.DOUBLE, Types.VARCHAR, Types.TIMESTAMP, Types.INTEGER));
+            Types.DOUBLE, Types.VARCHAR, Types.TIMESTAMP, Types.INTEGER, Types.DECIMAL));
 
     recordsInTableA = prepareInputRowsInTableA();
   }
@@ -122,6 +123,7 @@ public class BeamSqlDslBase {
     row1.addField(6, "string_row1");
     row1.addField(7, FORMAT.parse("2017-01-01 01:01:03"));
     row1.addField(8, 0);
+    row1.addField(9, new BigDecimal(1));
     rows.add(row1);
 
     BeamSqlRow row2 = new BeamSqlRow(rowTypeInTableA);
@@ -134,6 +136,7 @@ public class BeamSqlDslBase {
     row2.addField(6, "string_row2");
     row2.addField(7, FORMAT.parse("2017-01-01 01:02:03"));
     row2.addField(8, 0);
+    row2.addField(9, new BigDecimal(2));
     rows.add(row2);
 
     BeamSqlRow row3 = new BeamSqlRow(rowTypeInTableA);
@@ -146,6 +149,7 @@ public class BeamSqlDslBase {
     row3.addField(6, "string_row3");
     row3.addField(7, FORMAT.parse("2017-01-01 01:06:03"));
     row3.addField(8, 0);
+    row3.addField(9, new BigDecimal(3));
     rows.add(row3);
 
     BeamSqlRow row4 = new BeamSqlRow(rowTypeInTableA);
@@ -158,6 +162,7 @@ public class BeamSqlDslBase {
     row4.addField(6, "string_row4");
     row4.addField(7, FORMAT.parse("2017-01-01 02:04:03"));
     row4.addField(8, 0);
+    row4.addField(9, new BigDecimal(4));
     rows.add(row4);
 
     return rows;

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/test/java/org/apache/beam/dsls/sql/integrationtest/BeamSqlMathFunctionsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/test/java/org/apache/beam/dsls/sql/integrationtest/BeamSqlMathFunctionsIntegrationTest.java b/dsls/sql/src/test/java/org/apache/beam/dsls/sql/integrationtest/BeamSqlMathFunctionsIntegrationTest.java
index b8b8151..9f7d917 100644
--- a/dsls/sql/src/test/java/org/apache/beam/dsls/sql/integrationtest/BeamSqlMathFunctionsIntegrationTest.java
+++ b/dsls/sql/src/test/java/org/apache/beam/dsls/sql/integrationtest/BeamSqlMathFunctionsIntegrationTest.java
@@ -17,51 +17,335 @@
  */
 package org.apache.beam.dsls.sql.integrationtest;
 
-import java.io.Serializable;
-import java.util.Iterator;
+import java.math.BigDecimal;
 import java.util.Random;
-import org.apache.beam.dsls.sql.BeamSql;
-import org.apache.beam.dsls.sql.BeamSqlDslBase;
-import org.apache.beam.dsls.sql.schema.BeamSqlRow;
-import org.apache.beam.sdk.testing.PAssert;
-import org.apache.beam.sdk.transforms.SerializableFunction;
-import org.apache.beam.sdk.values.PCollection;
-import org.junit.Assert;
+import org.apache.calcite.runtime.SqlFunctions;
 import org.junit.Test;
 
 /**
- * Test cases for built-in Math functions.
+ * Integration test for built-in MATH functions.
  */
-public class BeamSqlMathFunctionsIntegrationTest extends BeamSqlDslBase implements Serializable {
+public class BeamSqlMathFunctionsIntegrationTest
+    extends BeamSqlBuiltinFunctionsIntegrationTestBase {
+  private static final int INTEGER_VALUE = 1;
+  private static final long LONG_VALUE = 1L;
+  private static final short SHORT_VALUE = 1;
+  private static final byte BYTE_VALUE = 1;
+  private static final double DOUBLE_VALUE = 1.0;
+  private static final float FLOAT_VALUE = 1.0f;
+  private static final BigDecimal DECIMAL_VALUE = new BigDecimal(1);
 
   @Test
-  public void testRandRandInteger() throws Exception {
-    String sql = "SELECT RAND(f_int) as a, RAND(100) as b, RAND() as c, "
-        + "RAND_INTEGER(10) as d, RAND_INTEGER(10, 100) as e "
-        + "FROM PCOLLECTION";
+  public void testAbs() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("ABS(c_integer)", Math.abs(INTEGER_VALUE))
+        .addExpr("ABS(c_bigint)", Math.abs(LONG_VALUE))
+        .addExpr("ABS(c_smallint)", (short) Math.abs(SHORT_VALUE))
+        .addExpr("ABS(c_tinyint)", (byte) Math.abs(BYTE_VALUE))
+        .addExpr("ABS(c_double)", Math.abs(DOUBLE_VALUE))
+        .addExpr("ABS(c_float)", Math.abs(FLOAT_VALUE))
+        .addExpr("ABS(c_decimal)", new BigDecimal(Math.abs(DECIMAL_VALUE.doubleValue())))
+        ;
 
-    PCollection<BeamSqlRow> result = boundedInput2
-        .apply("testRandRandInteger", BeamSql.simpleQuery(sql));
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testSqrt() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("SQRT(c_integer)", Math.sqrt(INTEGER_VALUE))
+        .addExpr("SQRT(c_bigint)", Math.sqrt(LONG_VALUE))
+        .addExpr("SQRT(c_smallint)", Math.sqrt(SHORT_VALUE))
+        .addExpr("SQRT(c_tinyint)", Math.sqrt(BYTE_VALUE))
+        .addExpr("SQRT(c_double)", Math.sqrt(DOUBLE_VALUE))
+        .addExpr("SQRT(c_float)", Math.sqrt(FLOAT_VALUE))
+        .addExpr("SQRT(c_decimal)", Math.sqrt(DECIMAL_VALUE.doubleValue()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testRound() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("ROUND(c_integer, 0)", SqlFunctions.sround(INTEGER_VALUE, 0))
+        .addExpr("ROUND(c_bigint, 0)", SqlFunctions.sround(LONG_VALUE, 0))
+        .addExpr("ROUND(c_smallint, 0)", (short) SqlFunctions.sround(SHORT_VALUE, 0))
+        .addExpr("ROUND(c_tinyint, 0)", (byte) SqlFunctions.sround(BYTE_VALUE, 0))
+        .addExpr("ROUND(c_double, 0)", SqlFunctions.sround(DOUBLE_VALUE, 0))
+        .addExpr("ROUND(c_float, 0)", (float) SqlFunctions.sround(FLOAT_VALUE, 0))
+        .addExpr("ROUND(c_decimal, 0)",
+            new BigDecimal(SqlFunctions.sround(DECIMAL_VALUE.doubleValue(), 0)))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testLn() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("LN(c_integer)", Math.log(INTEGER_VALUE))
+        .addExpr("LN(c_bigint)", Math.log(LONG_VALUE))
+        .addExpr("LN(c_smallint)", Math.log(SHORT_VALUE))
+        .addExpr("LN(c_tinyint)", Math.log(BYTE_VALUE))
+        .addExpr("LN(c_double)", Math.log(DOUBLE_VALUE))
+        .addExpr("LN(c_float)", Math.log(FLOAT_VALUE))
+        .addExpr("LN(c_decimal)", Math.log(DECIMAL_VALUE.doubleValue()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testLog10() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("LOG10(c_integer)", Math.log10(INTEGER_VALUE))
+        .addExpr("LOG10(c_bigint)", Math.log10(LONG_VALUE))
+        .addExpr("LOG10(c_smallint)", Math.log10(SHORT_VALUE))
+        .addExpr("LOG10(c_tinyint)", Math.log10(BYTE_VALUE))
+        .addExpr("LOG10(c_double)", Math.log10(DOUBLE_VALUE))
+        .addExpr("LOG10(c_float)", Math.log10(FLOAT_VALUE))
+        .addExpr("LOG10(c_decimal)", Math.log10(DECIMAL_VALUE.doubleValue()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testExp() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("EXP(c_integer)", Math.exp(INTEGER_VALUE))
+        .addExpr("EXP(c_bigint)", Math.exp(LONG_VALUE))
+        .addExpr("EXP(c_smallint)", Math.exp(SHORT_VALUE))
+        .addExpr("EXP(c_tinyint)", Math.exp(BYTE_VALUE))
+        .addExpr("EXP(c_double)", Math.exp(DOUBLE_VALUE))
+        .addExpr("EXP(c_float)", Math.exp(FLOAT_VALUE))
+        .addExpr("EXP(c_decimal)", Math.exp(DECIMAL_VALUE.doubleValue()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testAcos() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("ACOS(c_integer)", Math.acos(INTEGER_VALUE))
+        .addExpr("ACOS(c_bigint)", Math.acos(LONG_VALUE))
+        .addExpr("ACOS(c_smallint)", Math.acos(SHORT_VALUE))
+        .addExpr("ACOS(c_tinyint)", Math.acos(BYTE_VALUE))
+        .addExpr("ACOS(c_double)", Math.acos(DOUBLE_VALUE))
+        .addExpr("ACOS(c_float)", Math.acos(FLOAT_VALUE))
+        .addExpr("ACOS(c_decimal)", Math.acos(DECIMAL_VALUE.doubleValue()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testAsin() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("ASIN(c_integer)", Math.asin(INTEGER_VALUE))
+        .addExpr("ASIN(c_bigint)", Math.asin(LONG_VALUE))
+        .addExpr("ASIN(c_smallint)", Math.asin(SHORT_VALUE))
+        .addExpr("ASIN(c_tinyint)", Math.asin(BYTE_VALUE))
+        .addExpr("ASIN(c_double)", Math.asin(DOUBLE_VALUE))
+        .addExpr("ASIN(c_float)", Math.asin(FLOAT_VALUE))
+        .addExpr("ASIN(c_decimal)", Math.asin(DECIMAL_VALUE.doubleValue()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testAtan() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("ATAN(c_integer)", Math.atan(INTEGER_VALUE))
+        .addExpr("ATAN(c_bigint)", Math.atan(LONG_VALUE))
+        .addExpr("ATAN(c_smallint)", Math.atan(SHORT_VALUE))
+        .addExpr("ATAN(c_tinyint)", Math.atan(BYTE_VALUE))
+        .addExpr("ATAN(c_double)", Math.atan(DOUBLE_VALUE))
+        .addExpr("ATAN(c_float)", Math.atan(FLOAT_VALUE))
+        .addExpr("ATAN(c_decimal)", Math.atan(DECIMAL_VALUE.doubleValue()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testCot() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("COT(c_integer)", 1.0d / Math.tan(INTEGER_VALUE))
+        .addExpr("COT(c_bigint)", 1.0d / Math.tan(LONG_VALUE))
+        .addExpr("COT(c_smallint)", 1.0d / Math.tan(SHORT_VALUE))
+        .addExpr("COT(c_tinyint)", 1.0d / Math.tan(BYTE_VALUE))
+        .addExpr("COT(c_double)", 1.0d / Math.tan(DOUBLE_VALUE))
+        .addExpr("COT(c_float)", 1.0d / Math.tan(FLOAT_VALUE))
+        .addExpr("COT(c_decimal)", 1.0d / Math.tan(DECIMAL_VALUE.doubleValue()))
+        ;
 
-    PAssert.that(result).satisfies(new SerializableFunction<Iterable<BeamSqlRow>, Void>() {
-      @Override
-      public Void apply(Iterable<BeamSqlRow> input) {
-        Iterator<BeamSqlRow> ite = input.iterator();
-        Assert.assertTrue(ite.hasNext());
-        BeamSqlRow row = ite.next();
+    checker.buildRunAndCheck();
+  }
 
-        Assert.assertEquals(new Random(1).nextDouble(), row.getDouble(0), 0);
-        Assert.assertEquals(new Random(100).nextDouble(), row.getDouble(1), 0);
-        Assert.assertTrue(row.getDouble(2) >= 0 && row.getDouble(2) < 1);
+  @Test
+  public void testDegrees() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("DEGREES(c_integer)", Math.toDegrees(INTEGER_VALUE))
+        .addExpr("DEGREES(c_bigint)", Math.toDegrees(LONG_VALUE))
+        .addExpr("DEGREES(c_smallint)", Math.toDegrees(SHORT_VALUE))
+        .addExpr("DEGREES(c_tinyint)", Math.toDegrees(BYTE_VALUE))
+        .addExpr("DEGREES(c_double)", Math.toDegrees(DOUBLE_VALUE))
+        .addExpr("DEGREES(c_float)", Math.toDegrees(FLOAT_VALUE))
+        .addExpr("DEGREES(c_decimal)", Math.toDegrees(DECIMAL_VALUE.doubleValue()))
+        ;
 
-        Assert.assertTrue(row.getInteger(3) >= 0 && row.getInteger(3) < 10);
-        Assert.assertEquals(new Random(10).nextInt(100), row.getInteger(4));
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testRadians() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("RADIANS(c_integer)", Math.toRadians(INTEGER_VALUE))
+        .addExpr("RADIANS(c_bigint)", Math.toRadians(LONG_VALUE))
+        .addExpr("RADIANS(c_smallint)", Math.toRadians(SHORT_VALUE))
+        .addExpr("RADIANS(c_tinyint)", Math.toRadians(BYTE_VALUE))
+        .addExpr("RADIANS(c_double)", Math.toRadians(DOUBLE_VALUE))
+        .addExpr("RADIANS(c_float)", Math.toRadians(FLOAT_VALUE))
+        .addExpr("RADIANS(c_decimal)", Math.toRadians(DECIMAL_VALUE.doubleValue()))
+        ;
 
-        Assert.assertFalse(ite.hasNext());
-        return null;
-      }
-    });
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testCos() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("COS(c_integer)", Math.cos(INTEGER_VALUE))
+        .addExpr("COS(c_bigint)", Math.cos(LONG_VALUE))
+        .addExpr("COS(c_smallint)", Math.cos(SHORT_VALUE))
+        .addExpr("COS(c_tinyint)", Math.cos(BYTE_VALUE))
+        .addExpr("COS(c_double)", Math.cos(DOUBLE_VALUE))
+        .addExpr("COS(c_float)", Math.cos(FLOAT_VALUE))
+        .addExpr("COS(c_decimal)", Math.cos(DECIMAL_VALUE.doubleValue()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testSin() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("SIN(c_integer)", Math.sin(INTEGER_VALUE))
+        .addExpr("SIN(c_bigint)", Math.sin(LONG_VALUE))
+        .addExpr("SIN(c_smallint)", Math.sin(SHORT_VALUE))
+        .addExpr("SIN(c_tinyint)", Math.sin(BYTE_VALUE))
+        .addExpr("SIN(c_double)", Math.sin(DOUBLE_VALUE))
+        .addExpr("SIN(c_float)", Math.sin(FLOAT_VALUE))
+        .addExpr("SIN(c_decimal)", Math.sin(DECIMAL_VALUE.doubleValue()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testTan() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("TAN(c_integer)", Math.tan(INTEGER_VALUE))
+        .addExpr("TAN(c_bigint)", Math.tan(LONG_VALUE))
+        .addExpr("TAN(c_smallint)", Math.tan(SHORT_VALUE))
+        .addExpr("TAN(c_tinyint)", Math.tan(BYTE_VALUE))
+        .addExpr("TAN(c_double)", Math.tan(DOUBLE_VALUE))
+        .addExpr("TAN(c_float)", Math.tan(FLOAT_VALUE))
+        .addExpr("TAN(c_decimal)", Math.tan(DECIMAL_VALUE.doubleValue()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testSign() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("SIGN(c_integer)", Integer.signum(INTEGER_VALUE))
+        .addExpr("SIGN(c_bigint)", (long) (Long.signum(LONG_VALUE)))
+        .addExpr("SIGN(c_smallint)", (short) (Integer.signum(SHORT_VALUE)))
+        .addExpr("SIGN(c_tinyint)", (byte) Integer.signum(BYTE_VALUE))
+        .addExpr("SIGN(c_double)", Math.signum(DOUBLE_VALUE))
+        .addExpr("SIGN(c_float)", Math.signum(FLOAT_VALUE))
+        .addExpr("SIGN(c_decimal)", BigDecimal.valueOf(DECIMAL_VALUE.signum()))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testPower() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("POWER(c_integer, 2)", Math.pow(INTEGER_VALUE, 2))
+        .addExpr("POWER(c_bigint, 2)", Math.pow(LONG_VALUE, 2))
+        .addExpr("POWER(c_smallint, 2)", Math.pow(SHORT_VALUE, 2))
+        .addExpr("POWER(c_tinyint, 2)", Math.pow(BYTE_VALUE, 2))
+        .addExpr("POWER(c_double, 2)", Math.pow(DOUBLE_VALUE, 2))
+        .addExpr("POWER(c_float, 2)", Math.pow(FLOAT_VALUE, 2))
+        .addExpr("POWER(c_decimal, 2)", Math.pow(DECIMAL_VALUE.doubleValue(), 2))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testPi() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("PI", Math.PI)
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testAtan2() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("ATAN2(c_integer, 2)", Math.atan2(INTEGER_VALUE, 2))
+        .addExpr("ATAN2(c_bigint, 2)", Math.atan2(LONG_VALUE, 2))
+        .addExpr("ATAN2(c_smallint, 2)", Math.atan2(SHORT_VALUE, 2))
+        .addExpr("ATAN2(c_tinyint, 2)", Math.atan2(BYTE_VALUE, 2))
+        .addExpr("ATAN2(c_double, 2)", Math.atan2(DOUBLE_VALUE, 2))
+        .addExpr("ATAN2(c_float, 2)", Math.atan2(FLOAT_VALUE, 2))
+        .addExpr("ATAN2(c_decimal, 2)", Math.atan2(DECIMAL_VALUE.doubleValue(), 2))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testTruncate() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("TRUNCATE(c_integer, 2)", SqlFunctions.struncate(INTEGER_VALUE, 2))
+        .addExpr("TRUNCATE(c_bigint, 2)", SqlFunctions.struncate(LONG_VALUE, 2))
+        .addExpr("TRUNCATE(c_smallint, 2)", (short) SqlFunctions.struncate(SHORT_VALUE, 2))
+        .addExpr("TRUNCATE(c_tinyint, 2)", (byte) SqlFunctions.struncate(BYTE_VALUE, 2))
+        .addExpr("TRUNCATE(c_double, 2)", SqlFunctions.struncate(DOUBLE_VALUE, 2))
+        .addExpr("TRUNCATE(c_float, 2)", (float) SqlFunctions.struncate(FLOAT_VALUE, 2))
+        .addExpr("TRUNCATE(c_decimal, 2)", SqlFunctions.struncate(DECIMAL_VALUE, 2))
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testRand() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("RAND(c_integer)", new Random(INTEGER_VALUE).nextDouble())
+        ;
+
+    checker.buildRunAndCheck();
+  }
+
+  @Test
+  public void testRandInteger() throws Exception{
+    ExpressionChecker checker = new ExpressionChecker()
+        .addExpr("RAND_INTEGER(c_integer, c_integer)",
+            new Random(INTEGER_VALUE).nextInt(INTEGER_VALUE))
+        ;
 
-    pipeline.run().waitUntilFinish();
+    checker.buildRunAndCheck();
   }
 }

http://git-wip-us.apache.org/repos/asf/beam/blob/7f5cbbae/dsls/sql/src/test/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathUnaryExpressionTest.java
----------------------------------------------------------------------
diff --git a/dsls/sql/src/test/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathUnaryExpressionTest.java b/dsls/sql/src/test/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathUnaryExpressionTest.java
index 510c65e..71c98d4 100644
--- a/dsls/sql/src/test/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathUnaryExpressionTest.java
+++ b/dsls/sql/src/test/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlMathUnaryExpressionTest.java
@@ -41,7 +41,6 @@ public class BeamSqlMathUnaryExpressionTest extends BeamSqlFnExecutorTestBase {
     operands.add(BeamSqlPrimitive.of(SqlTypeName.INTEGER, 2));
     operands.add(BeamSqlPrimitive.of(SqlTypeName.INTEGER, 4));
     Assert.assertFalse(new BeamSqlAbsExpression(operands).accept());
-    Assert.assertFalse(new BeamSqlSqrtExpression(operands).accept());
   }
 
   @Test public void testForOperandsType() {
@@ -50,7 +49,6 @@ public class BeamSqlMathUnaryExpressionTest extends BeamSqlFnExecutorTestBase {
     // varchar operand not allowed
     operands.add(BeamSqlPrimitive.of(SqlTypeName.VARCHAR, "2"));
     Assert.assertFalse(new BeamSqlAbsExpression(operands).accept());
-    Assert.assertFalse(new BeamSqlSqrtExpression(operands).accept());
   }
 
   @Test public void testForUnaryExpressions() {
@@ -58,8 +56,6 @@ public class BeamSqlMathUnaryExpressionTest extends BeamSqlFnExecutorTestBase {
 
     // test for sqrt function
     operands.add(BeamSqlPrimitive.of(SqlTypeName.SMALLINT, Short.valueOf("2")));
-    Assert.assertEquals(1.4142135623730951,
-        new BeamSqlSqrtExpression(operands).evaluate(record).getValue());
 
     // test for abs function
     operands.clear();
@@ -281,7 +277,7 @@ public class BeamSqlMathUnaryExpressionTest extends BeamSqlFnExecutorTestBase {
 
     // test for exp function with operand type smallint
     operands.add(BeamSqlPrimitive.of(SqlTypeName.SMALLINT, Short.valueOf("2")));
-    Assert.assertEquals(1, new BeamSqlSignExpression(operands).evaluate(record).getValue());
+    Assert.assertEquals((short) 1, new BeamSqlSignExpression(operands).evaluate(record).getValue());
     // test for exp function with operand type double
     operands.clear();
     operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 2.4));


Mime
View raw message