[2/2] phoenix git commit: PHOENIX-1660 Implement missing math built-in functions ABS, POWER, LN, LOG, SQRT, CBRT, EXP (Shuxiong Ye)
PHOENIX-1660 Implement missing math built-in functions ABS, POWER, LN, LOG, SQRT, CBRT, EXP (Shuxiong Ye) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b618234d Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b618234d Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b618234d Branch: refs/heads/4.x-HBase-1.0 Commit: b618234d601d2805d27081c6c52a9c8bfbd30d69 Parents: 04406c8 Author: James Taylor jamestay...@apache.org Authored: Mon Jun 15 15:53:44 2015 -0700 Committer: James Taylor jamestay...@apache.org Committed: Mon Jun 15 16:27:38 2015 -0700 -- .../phoenix/end2end/AbsFunctionEnd2EndIT.java | 108 +++ .../phoenix/end2end/CbrtFunctionEnd2EndIT.java | 143 +++ .../phoenix/end2end/ExpFunctionEnd2EndIT.java | 128 + .../phoenix/end2end/LnLogFunctionEnd2EndIT.java | 143 +++ .../phoenix/end2end/PowerFunctionEnd2EndIT.java | 144 +++ .../phoenix/expression/ExpressionType.java | 14 +- .../expression/function/AbsFunction.java| 66 +++ .../expression/function/CbrtFunction.java | 55 ++ .../expression/function/ExpFunction.java| 55 ++ .../function/JavaMathOneArgumentFunction.java | 43 ++--- .../function/JavaMathTwoArgumentFunction.java | 69 +++ .../phoenix/expression/function/LnFunction.java | 55 ++ .../expression/function/LogFunction.java| 56 ++ .../expression/function/PowerFunction.java | 51 ++ .../expression/function/ScalarFunction.java | 4 +- .../expression/function/SqrtFunction.java | 8 +- .../apache/phoenix/schema/types/PDecimal.java | 11 ++ .../phoenix/schema/types/PNumericType.java | 8 + .../phoenix/schema/types/PRealNumber.java | 8 + .../phoenix/schema/types/PWholeNumber.java | 8 + .../phoenix/compile/QueryCompilerTest.java | 68 ++- .../phoenix/expression/AbsFunctionTest.java | 180 ++ .../phoenix/expression/CbrtFunctionTest.java| 127 + .../phoenix/expression/ExpFunctionTest.java | 150 +++ .../phoenix/expression/LnLogFunctionTest.java | 182 +++ .../phoenix/expression/PowerFunctionTest.java | 182 +++ 26 files changed, 2036 insertions(+), 30 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/b618234d/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java new file mode 100644 index 000..0c6204c --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java @@ -0,0 +1,108 @@ +/* + * 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.phoenix.end2end; + +import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; + +import org.apache.phoenix.expression.function.AbsFunction; +import org.junit.Before; +import org.junit.Test; + +/** + * End to end tests for {@link AbsFunction} + */ +public class AbsFunctionEnd2EndIT extends BaseHBaseManagedTimeIT { + +private static final String KEY = key; + +@Before +public void initTable() throws Exception { +Connection conn = null; +PreparedStatement stmt = null; +try { +conn = DriverManager.getConnection(getUrl()); +String ddl; +ddl = CREATE TABLE testSigned (k VARCHAR NOT NULL PRIMARY KEY, dec DECIMAL, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT); +conn.createStatement().execute(ddl); +
[2/2] phoenix git commit: PHOENIX-1660 Implement missing math built-in functions ABS, POWER, LN, LOG, SQRT, CBRT, EXP (Shuxiong Ye)
PHOENIX-1660 Implement missing math built-in functions ABS, POWER, LN, LOG, SQRT, CBRT, EXP (Shuxiong Ye) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/c2927dde Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c2927dde Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c2927dde Branch: refs/heads/master Commit: c2927ddec5ab954dd779516ed29b4b7fa4b011d9 Parents: d1934af Author: James Taylor jamestay...@apache.org Authored: Mon Jun 15 15:53:44 2015 -0700 Committer: James Taylor jamestay...@apache.org Committed: Mon Jun 15 15:53:44 2015 -0700 -- .../phoenix/end2end/AbsFunctionEnd2EndIT.java | 108 +++ .../phoenix/end2end/CbrtFunctionEnd2EndIT.java | 143 +++ .../phoenix/end2end/ExpFunctionEnd2EndIT.java | 128 + .../phoenix/end2end/LnLogFunctionEnd2EndIT.java | 143 +++ .../phoenix/end2end/PowerFunctionEnd2EndIT.java | 144 +++ .../phoenix/expression/ExpressionType.java | 14 +- .../expression/function/AbsFunction.java| 66 +++ .../expression/function/CbrtFunction.java | 55 ++ .../expression/function/ExpFunction.java| 55 ++ .../function/JavaMathOneArgumentFunction.java | 43 ++--- .../function/JavaMathTwoArgumentFunction.java | 69 +++ .../phoenix/expression/function/LnFunction.java | 55 ++ .../expression/function/LogFunction.java| 56 ++ .../expression/function/PowerFunction.java | 51 ++ .../expression/function/ScalarFunction.java | 4 +- .../expression/function/SqrtFunction.java | 8 +- .../apache/phoenix/schema/types/PDecimal.java | 11 ++ .../phoenix/schema/types/PNumericType.java | 8 + .../phoenix/schema/types/PRealNumber.java | 8 + .../phoenix/schema/types/PWholeNumber.java | 8 + .../phoenix/compile/QueryCompilerTest.java | 68 ++- .../phoenix/expression/AbsFunctionTest.java | 180 ++ .../phoenix/expression/CbrtFunctionTest.java| 127 + .../phoenix/expression/ExpFunctionTest.java | 150 +++ .../phoenix/expression/LnLogFunctionTest.java | 182 +++ .../phoenix/expression/PowerFunctionTest.java | 182 +++ 26 files changed, 2036 insertions(+), 30 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/c2927dde/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java new file mode 100644 index 000..0c6204c --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java @@ -0,0 +1,108 @@ +/* + * 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.phoenix.end2end; + +import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; + +import org.apache.phoenix.expression.function.AbsFunction; +import org.junit.Before; +import org.junit.Test; + +/** + * End to end tests for {@link AbsFunction} + */ +public class AbsFunctionEnd2EndIT extends BaseHBaseManagedTimeIT { + +private static final String KEY = key; + +@Before +public void initTable() throws Exception { +Connection conn = null; +PreparedStatement stmt = null; +try { +conn = DriverManager.getConnection(getUrl()); +String ddl; +ddl = CREATE TABLE testSigned (k VARCHAR NOT NULL PRIMARY KEY, dec DECIMAL, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT); +conn.createStatement().execute(ddl); +conn.commit();