Repository: beam Updated Branches: refs/heads/DSL_SQL a680904a4 -> bf39926b4
Add ACOS, ASIN, ATAN, COS, COT, DEGREES, RADIANS, SIN, TAN, SIGN, LN, LOG10, EXP Functions Project: http://git-wip-us.apache.org/repos/asf/beam/repo Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/eec3a03a Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/eec3a03a Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/eec3a03a Branch: refs/heads/DSL_SQL Commit: eec3a03a4e94a60669a932a2709454779613e2d4 Parents: a680904 Author: tarushapptech <[email protected]> Authored: Sun Jun 18 22:41:41 2017 +0530 Committer: Tyler Akidau <[email protected]> Committed: Thu Jun 22 13:21:43 2017 -0700 ---------------------------------------------------------------------- .../dsls/sql/interpreter/BeamSqlFnExecutor.java | 48 ++++ .../operator/math/BeamSqlAcosExpression.java | 41 ++++ .../operator/math/BeamSqlAsinExpression.java | 41 ++++ .../operator/math/BeamSqlAtanExpression.java | 41 ++++ .../operator/math/BeamSqlCosExpression.java | 41 ++++ .../operator/math/BeamSqlCotExpression.java | 41 ++++ .../operator/math/BeamSqlDegreesExpression.java | 41 ++++ .../operator/math/BeamSqlExpExpression.java | 41 ++++ .../operator/math/BeamSqlLnExpression.java | 41 ++++ .../operator/math/BeamSqlLogExpression.java | 41 ++++ .../operator/math/BeamSqlRadiansExpression.java | 41 ++++ .../operator/math/BeamSqlSignExpression.java | 61 +++++ .../operator/math/BeamSqlSinExpression.java | 41 ++++ .../operator/math/BeamSqlTanExpression.java | 41 ++++ .../math/BeamSqlMathUnaryExpressionTest.java | 228 ++++++++++++++++++- 15 files changed, 828 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 091dbf7..4678da5 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 @@ -54,8 +54,20 @@ import org.apache.beam.dsls.sql.interpreter.operator.logical.BeamSqlAndExpressio import org.apache.beam.dsls.sql.interpreter.operator.logical.BeamSqlNotExpression; import org.apache.beam.dsls.sql.interpreter.operator.logical.BeamSqlOrExpression; import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlAbsExpression; +import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlAcosExpression; +import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlAsinExpression; +import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlAtanExpression; +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; +import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlLnExpression; +import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlLogExpression; +import org.apache.beam.dsls.sql.interpreter.operator.math.BeamSqlRadiansExpression; 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.string.BeamSqlCharLengthExpression; import org.apache.beam.dsls.sql.interpreter.operator.string.BeamSqlConcatExpression; import org.apache.beam.dsls.sql.interpreter.operator.string.BeamSqlInitCapExpression; @@ -230,6 +242,42 @@ public class BeamSqlFnExecutor implements BeamSqlExpressionExecutor { case "ROUND": ret = new BeamSqlRoundExpression(subExps); break; + case "LN": + ret = new BeamSqlLnExpression(subExps); + break; + case "LOG10": + ret = new BeamSqlLogExpression(subExps); + break; + case "EXP": + ret = new BeamSqlExpExpression(subExps); + break; + case "ACOS": + ret = new BeamSqlAcosExpression(subExps); + break; + case "ASIN": + ret = new BeamSqlAsinExpression(subExps); + break; + case "ATAN": + ret = new BeamSqlAtanExpression(subExps); + break; + case "COT": + ret = new BeamSqlCotExpression(subExps); + break; + case "DEGREES": + ret = new BeamSqlDegreesExpression(subExps); + break; + case "RADIANS": + ret = new BeamSqlRadiansExpression(subExps); + break; + case "SIN": + ret = new BeamSqlSinExpression(subExps); + break; + case "TAN": + ret = new BeamSqlTanExpression(subExps); + break; + case "SIGN": + ret = new BeamSqlSignExpression(subExps); + break; // string operators case "||": http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..a74ed0d --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAcosExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'ACOS' function. + */ +public class BeamSqlAcosExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlAcosExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.acos(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..c30d6d3 --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAsinExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'ASIN' function. + */ +public class BeamSqlAsinExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlAsinExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.asin(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..05c1bf6 --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlAtanExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'ATAN' function. + */ +public class BeamSqlAtanExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlAtanExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.atan(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..2e1334b --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCosExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'COS' function. + */ +public class BeamSqlCosExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlCosExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.cos(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..8fd83ed --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlCotExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'COT' function. + */ +public class BeamSqlCotExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlCotExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.cot(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..2cbaf35 --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlDegreesExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'DEGREES' function. + */ +public class BeamSqlDegreesExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlDegreesExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.degrees(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..d2b3497 --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlExpExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'EXP' function. + */ +public class BeamSqlExpExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlExpExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.exp(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..a30d1ca --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLnExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'LN' function. + */ +public class BeamSqlLnExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlLnExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.ln(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..c83f816 --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlLogExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'Log10' function. + */ +public class BeamSqlLogExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlLogExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.log10(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..1ec8099 --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlRadiansExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'RADIANS' function. + */ +public class BeamSqlRadiansExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlRadiansExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.radians(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..3ca42e6 --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSignExpression.java @@ -0,0 +1,61 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'SIGN' function. + */ +public class BeamSqlSignExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlSignExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + BeamSqlPrimitive result = null; + switch (op.getOutputType()) { + case TINYINT: + case SMALLINT: + case INTEGER: + result = BeamSqlPrimitive + .of(SqlTypeName.INTEGER, SqlFunctions.sign(SqlFunctions.toInt(op.getValue()))); + break; + case BIGINT: + result = BeamSqlPrimitive + .of(SqlTypeName.BIGINT, SqlFunctions.sign(SqlFunctions.toLong(op.getValue()))); + break; + case FLOAT: + case DOUBLE: + result = BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.sign(SqlFunctions.toDouble(op.getValue()))); + break; + case DECIMAL: + result = BeamSqlPrimitive + .of(SqlTypeName.DECIMAL, SqlFunctions.sign(SqlFunctions.toBigDecimal(op.getValue()))); + break; + } + return result; + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..a7efd69 --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlSinExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'SIN' function. + */ +public class BeamSqlSinExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlSinExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.sin(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 new file mode 100644 index 0000000..4d43408 --- /dev/null +++ b/dsls/sql/src/main/java/org/apache/beam/dsls/sql/interpreter/operator/math/BeamSqlTanExpression.java @@ -0,0 +1,41 @@ +/* + * 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.runtime.SqlFunctions; +import org.apache.calcite.sql.type.SqlTypeName; + +/** + * {@code BeamSqlMathUnaryExpression} for 'TAN' function. + */ +public class BeamSqlTanExpression extends BeamSqlMathUnaryExpression { + + public BeamSqlTanExpression(List<BeamSqlExpression> operands) { + super(operands); + } + + @Override public BeamSqlPrimitive calculate(BeamSqlPrimitive op) { + return BeamSqlPrimitive + .of(SqlTypeName.DOUBLE, SqlFunctions.tan(SqlFunctions.toDouble(op.getValue()))); + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/eec3a03a/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 e3b0d18..38f5db6 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 @@ -18,8 +18,10 @@ package org.apache.beam.dsls.sql.interpreter.operator.math; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; + import org.apache.beam.dsls.sql.interpreter.BeamSqlFnExecutorTestBase; import org.apache.beam.dsls.sql.interpreter.operator.BeamSqlExpression; import org.apache.beam.dsls.sql.interpreter.operator.BeamSqlPrimitive; @@ -27,7 +29,6 @@ import org.apache.calcite.sql.type.SqlTypeName; import org.junit.Assert; import org.junit.Test; - /** * Test for {@link BeamSqlMathUnaryExpression}. */ @@ -67,4 +68,229 @@ public class BeamSqlMathUnaryExpressionTest extends BeamSqlFnExecutorTestBase { .assertEquals(28965734597L, new BeamSqlAbsExpression(operands).evaluate(record).getValue()); } + @Test public void testForLnExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for LN function with operand type smallint + operands.add(BeamSqlPrimitive.of(SqlTypeName.SMALLINT, Short.valueOf("2"))); + Assert.assertEquals(Math.log(2), new BeamSqlLnExpression(operands).evaluate(record).getValue()); + + // test for LN function with operand type double + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 2.4)); + Assert + .assertEquals(Math.log(2.4), new BeamSqlLnExpression(operands).evaluate(record).getValue()); + // test for LN function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(2.56))); + Assert.assertEquals(Math.log(2.56), + new BeamSqlLnExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForLog10Expression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for log10 function with operand type smallint + operands.add(BeamSqlPrimitive.of(SqlTypeName.SMALLINT, Short.valueOf("2"))); + Assert.assertEquals(Math.log10(2), + new BeamSqlLogExpression(operands).evaluate(record).getValue()); + // test for log10 function with operand type double + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 2.4)); + Assert.assertEquals(Math.log10(2.4), + new BeamSqlLogExpression(operands).evaluate(record).getValue()); + // test for log10 function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(2.56))); + Assert.assertEquals(Math.log10(2.56), + new BeamSqlLogExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForExpExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for exp function with operand type smallint + operands.add(BeamSqlPrimitive.of(SqlTypeName.SMALLINT, Short.valueOf("2"))); + Assert + .assertEquals(Math.exp(2), new BeamSqlExpExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type double + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 2.4)); + Assert.assertEquals(Math.exp(2.4), + new BeamSqlExpExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(2.56))); + Assert.assertEquals(Math.exp(2.56), + new BeamSqlExpExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForAcosExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for exp function with operand type smallint + operands.add(BeamSqlPrimitive.of(SqlTypeName.SMALLINT, Short.valueOf("2"))); + Assert + .assertEquals(Double.NaN, new BeamSqlAcosExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type double + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 0.45)); + Assert.assertEquals(Math.acos(0.45), + new BeamSqlAcosExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(-0.367))); + Assert.assertEquals(Math.acos(-0.367), + new BeamSqlAcosExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForAsinExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for exp function with operand type double + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 0.45)); + Assert.assertEquals(Math.asin(0.45), + new BeamSqlAsinExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(-0.367))); + Assert.assertEquals(Math.asin(-0.367), + new BeamSqlAsinExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForAtanExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for exp function with operand type double + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 0.45)); + Assert.assertEquals(Math.atan(0.45), + new BeamSqlAtanExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(-0.367))); + Assert.assertEquals(Math.atan(-0.367), + new BeamSqlAtanExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForCosExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for exp function with operand type double + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 0.45)); + Assert.assertEquals(Math.cos(0.45), + new BeamSqlCosExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(-0.367))); + Assert.assertEquals(Math.cos(-0.367), + new BeamSqlCosExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForCotExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for exp function with operand type double + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, .45)); + Assert.assertEquals(1.0d / Math.tan(0.45), + new BeamSqlCotExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(-.367))); + Assert.assertEquals(1.0d / Math.tan(-0.367), + new BeamSqlCotExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForDegreesExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for exp function with operand type smallint + operands.add(BeamSqlPrimitive.of(SqlTypeName.SMALLINT, Short.valueOf("2"))); + Assert.assertEquals(Math.toDegrees(2), + new BeamSqlDegreesExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type double + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 2.4)); + Assert.assertEquals(Math.toDegrees(2.4), + new BeamSqlDegreesExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(2.56))); + Assert.assertEquals(Math.toDegrees(2.56), + new BeamSqlDegreesExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForRadiansExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for exp function with operand type smallint + operands.add(BeamSqlPrimitive.of(SqlTypeName.SMALLINT, Short.valueOf("2"))); + Assert.assertEquals(Math.toRadians(2), + new BeamSqlRadiansExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type double + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 2.4)); + Assert.assertEquals(Math.toRadians(2.4), + new BeamSqlRadiansExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(2.56))); + Assert.assertEquals(Math.toRadians(2.56), + new BeamSqlRadiansExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForSinExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for exp function with operand type smallint + operands.add(BeamSqlPrimitive.of(SqlTypeName.SMALLINT, Short.valueOf("2"))); + Assert + .assertEquals(Math.sin(2), new BeamSqlSinExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type double + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 2.4)); + Assert.assertEquals(Math.sin(2.4), + new BeamSqlSinExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(2.56))); + Assert.assertEquals(Math.sin(2.56), + new BeamSqlSinExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForTanExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // test for exp function with operand type smallint + operands.add(BeamSqlPrimitive.of(SqlTypeName.SMALLINT, Short.valueOf("2"))); + Assert + .assertEquals(Math.tan(2), new BeamSqlTanExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type double + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 2.4)); + Assert.assertEquals(Math.tan(2.4), + new BeamSqlTanExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(2.56))); + Assert.assertEquals(Math.tan(2.56), + new BeamSqlTanExpression(operands).evaluate(record).getValue()); + } + + @Test public void testForSignExpression() { + List<BeamSqlExpression> operands = new ArrayList<>(); + + // 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()); + // test for exp function with operand type double + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DOUBLE, 2.4)); + Assert.assertEquals(1.0, new BeamSqlSignExpression(operands).evaluate(record).getValue()); + // test for exp function with operand type decimal + operands.clear(); + operands.add(BeamSqlPrimitive.of(SqlTypeName.DECIMAL, BigDecimal.valueOf(2.56))); + Assert.assertEquals(BigDecimal.ONE, + new BeamSqlSignExpression(operands).evaluate(record).getValue()); + } + }
