DRILL-710: Fix sign function to always return integer type.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/61fc5ea8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/61fc5ea8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/61fc5ea8 Branch: refs/heads/master Commit: 61fc5ea82ea32e327f5ce5f556826e615a71233c Parents: fd6cdf8 Author: Mehant Baid <[email protected]> Authored: Tue Jun 3 22:15:31 2014 -0700 Committer: Jacques Nadeau <[email protected]> Committed: Wed Jun 4 16:39:22 2014 -0700 ---------------------------------------------------------------------- exec/java-exec/src/main/codegen/data/MathFunc.tdd | 18 +++++++++--------- .../drill/jdbc/test/TestFunctionsQuery.java | 13 +++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/61fc5ea8/exec/java-exec/src/main/codegen/data/MathFunc.tdd ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/data/MathFunc.tdd b/exec/java-exec/src/main/codegen/data/MathFunc.tdd index 228d207..e287122 100644 --- a/exec/java-exec/src/main/codegen/data/MathFunc.tdd +++ b/exec/java-exec/src/main/codegen/data/MathFunc.tdd @@ -96,15 +96,15 @@ }, {className: "Sign", funcName: "sign", javaFunc : "java.lang.Math.signum", types: [ {input: "Int", outputType: "Int", castType: "int"}, - {input: "BigInt", outputType: "BigInt", castType: "long"}, - {input: "Float4", outputType: "Float4", castType: "float"}, - {input: "Float8", outputType: "Float8", castType: "double"}, - {input: "SmallInt", outputType: "SmallInt", castType: "short"}, - {input: "TinyInt", outputType: "TinyInt", castType: "byte"}, - {input: "UInt1", outputType: "UInt1", castType: "byte"}, - {input: "UInt2", outputType: "UInt2", castType: "char"}, - {input: "UInt4", outputType: "UInt4", castType: "int"}, - {input: "UInt8", outputType: "UInt8", castType: "long"} + {input: "BigInt", outputType: "Int", castType: "int"}, + {input: "Float4", outputType: "Int", castType: "int"}, + {input: "Float8", outputType: "Int", castType: "int"}, + {input: "SmallInt", outputType: "Int", castType: "int"}, + {input: "TinyInt", outputType: "Int", castType: "int"}, + {input: "UInt1", outputType: "Int", castType: "int"}, + {input: "UInt2", outputType: "Int", castType: "int"}, + {input: "UInt4", outputType: "Int", castType: "int"}, + {input: "UInt8", outputType: "Int", castType: "int"} ] } ], http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/61fc5ea8/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestFunctionsQuery.java ---------------------------------------------------------------------- diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestFunctionsQuery.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestFunctionsQuery.java index 66ae477..0dacfa3 100644 --- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestFunctionsQuery.java +++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestFunctionsQuery.java @@ -467,4 +467,17 @@ public class TestFunctionsQuery { "DEC_38=3.00000\n"); } + @Test + public void testSignFunction() throws Exception { + String query = "select sign(cast('1.23' as float)) as SIGN_FLOAT, sign(-1234.4567) as SIGN_DOUBLE, sign(23) as SIGN_INT " + + "from cp.`employee.json` where employee_id < 2"; + + JdbcAssert.withNoDefaultSchema() + .sql(query) + .returns( + "SIGN_FLOAT=1; " + + "SIGN_DOUBLE=-1; " + + "SIGN_INT=1\n"); + } + }
