[ASTERIXDB-2423][RT] Division by zero should return NULL - user model changes: yes - storage format changes: no - interface changes: no
Details: - Make DIV, /, MOD operators return NULL if the divisor is 0 - Add test case for if_inf() function Change-Id: If2a45e842b840f721435b0715945a209e55b9dd4 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2813 Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Till Westmann <ti...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/6b1b52c1 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/6b1b52c1 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/6b1b52c1 Branch: refs/heads/master Commit: 6b1b52c1f4eb5a1e6abe7f82af3da3a45e8ea3ac Parents: 0e70ad6 Author: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Authored: Thu Jul 26 12:56:37 2018 -0700 Committer: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Committed: Fri Jul 27 17:37:47 2018 -0700 ---------------------------------------------------------------------- .../divide_double/divide_double.1.query.aql | 2 +- .../divide_float/divide_float.1.query.aql | 2 +- .../divide_int16/divide_int16.1.query.aql | 2 +- .../divide_int16/divide_int16.2.query.aql | 2 +- .../divide_int32/divide_int32.1.query.aql | 2 +- .../divide_int32/divide_int32.2.query.aql | 2 +- .../divide_int64/divide_int64.1.query.aql | 2 +- .../divide_int64/divide_int64.2.query.aql | 2 +- .../numeric/divide_int8/divide_int8.1.query.aql | 2 +- .../numeric/divide_int8/divide_int8.2.query.aql | 2 +- .../divide_double/divide_double.1.query.sqlpp | 2 +- .../divide_float/divide_float.1.query.sqlpp | 2 +- .../divide_int16/divide_int16.1.query.sqlpp | 2 +- .../divide_int16/divide_int16.2.query.sqlpp | 2 +- .../divide_int32/divide_int32.1.query.sqlpp | 2 +- .../divide_int32/divide_int32.2.query.sqlpp | 2 +- .../divide_int64/divide_int64.1.query.sqlpp | 2 +- .../divide_int64/divide_int64.2.query.sqlpp | 2 +- .../divide_int8/divide_int8.1.query.sqlpp | 2 +- .../divide_int8/divide_int8.2.query.sqlpp | 2 +- .../numeric/ifinf/ifinf.1.query.sqlpp | 3 +- .../numeric/divide_double/divide_double.1.adm | 2 +- .../numeric/divide_float/divide_float.1.adm | 2 +- .../numeric/divide_int16/divide_int16.1.adm | 2 +- .../numeric/divide_int16/divide_int16.2.adm | 2 +- .../numeric/divide_int32/divide_int32.1.adm | 2 +- .../numeric/divide_int32/divide_int32.2.adm | 2 +- .../numeric/divide_int64/divide_int64.1.adm | 2 +- .../numeric/divide_int64/divide_int64.2.adm | 2 +- .../numeric/divide_int8/divide_int8.1.adm | 2 +- .../numeric/divide_int8/divide_int8.2.adm | 2 +- .../runtimets/results/numeric/ifinf/ifinf.1.adm | 3 +- .../numeric/divide_double/divide_double.1.ast | 11 + .../numeric/divide_float/divide_float.1.ast | 11 + .../numeric/divide_int16/divide_int16.1.ast | 19 +- .../numeric/divide_int16/divide_int16.2.ast | 19 +- .../numeric/divide_int32/divide_int32.1.ast | 19 +- .../numeric/divide_int32/divide_int32.2.ast | 19 +- .../numeric/divide_int64/divide_int64.1.ast | 19 +- .../numeric/divide_int64/divide_int64.2.ast | 19 +- .../numeric/divide_int8/divide_int8.1.ast | 19 +- .../numeric/divide_int8/divide_int8.2.ast | 19 +- .../asterix/common/exceptions/ErrorCode.java | 1 - .../main/resources/asx_errormsg/en.properties | 1 - .../asterix/om/functions/BuiltinFunctions.java | 4 +- .../impl/NumericAddSubMulDivTypeComputer.java | 20 +- .../impl/NumericDivideTypeComputer.java | 7 + .../AbstractNumericArithmeticEval.java | 223 ++++++++++++------- .../functions/NumericAddDescriptor.java | 30 ++- .../functions/NumericDivDescriptor.java | 27 ++- .../functions/NumericDivideDescriptor.java | 19 +- .../functions/NumericModuloDescriptor.java | 27 ++- .../functions/NumericMultiplyDescriptor.java | 26 ++- .../functions/NumericPowerDescriptor.java | 26 ++- .../functions/NumericSubDescriptor.java | 33 ++- 55 files changed, 477 insertions(+), 207 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_double/divide_double.1.query.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_double/divide_double.1.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_double/divide_double.1.query.aql index 62b1112..f86aae9 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_double/divide_double.1.query.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_double/divide_double.1.query.aql @@ -24,4 +24,4 @@ let $c4 := int64("-4") let $c5 := float("-5.5f") let $c6 := double("-6.5d") let $c8 := null -return {"result1": $c6/$c1,"result2": $c6/$c2,"result3": $c6/$c3,"result4": $c6/$c4,"result5": $c6/$c5, "result6": $c6/$c6, "result7": $c6/$c8, "result8": $c6/[1][1]} +return {"result1": $c6/$c1,"result2": $c6/$c2,"result3": $c6/$c3,"result4": $c6/$c4,"result5": $c6/$c5, "result6": $c6/$c6, "result7": $c6/$c8, "result8": $c6/[1][1], "result9": $c6/0} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_float/divide_float.1.query.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_float/divide_float.1.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_float/divide_float.1.query.aql index 0f938e3..dde8291 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_float/divide_float.1.query.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_float/divide_float.1.query.aql @@ -24,4 +24,4 @@ let $c4 := int64("-4") let $c5 := float("-5.5f") let $c6 := double("-6.5d") let $c8 := null -return {"result1": $c5/$c1,"result2": $c5/$c2,"result3": $c5/$c3,"result4": $c5/$c4,"result5": $c5/$c5, "result6": $c5/$c6, "result7": $c6/$c8, "result8": $c6/[1][1]} +return {"result1": $c5/$c1,"result2": $c5/$c2,"result3": $c5/$c3,"result4": $c5/$c4,"result5": $c5/$c5, "result6": $c5/$c6, "result7": $c6/$c8, "result8": $c6/[1][1], "result9": $c6/0} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int16/divide_int16.1.query.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int16/divide_int16.1.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int16/divide_int16.1.query.aql index 17f19c0..e4993d4 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int16/divide_int16.1.query.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int16/divide_int16.1.query.aql @@ -24,4 +24,4 @@ let $c4 := int64("-4") let $c5 := float("-5.5f") let $c6 := double("-6.5d") let $c8 := null -return {"result1": $c2/$c1,"result2": $c2/$c2,"result3": $c2/$c3,"result4": $c2/$c4,"result5": $c2/$c5, "result6": $c2/$c6, "result7": $c6/$c8, "result8": $c6/[1][1]} +return {"result1": $c2/$c1,"result2": $c2/$c2,"result3": $c2/$c3,"result4": $c2/$c4,"result5": $c2/$c5, "result6": $c2/$c6, "result7": $c6/$c8, "result8": $c6/[1][1], "result9": $c6/0} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int16/divide_int16.2.query.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int16/divide_int16.2.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int16/divide_int16.2.query.aql index b59be3b..1771d70 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int16/divide_int16.2.query.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int16/divide_int16.2.query.aql @@ -24,4 +24,4 @@ let $c4 := int64("-4") let $c5 := float("-5.5f") let $c6 := double("-6.5d") let $c8 := null -return {"result1": $c2 div $c1,"result2": $c2 div $c2,"result3": $c2 div $c3,"result4": $c2 div $c4,"result5": $c2 div $c5, "result6": $c2 div $c6, "result7": $c6 div $c8, "result8": $c6 div [1][1]} +return {"result1": $c2 div $c1,"result2": $c2 div $c2,"result3": $c2 div $c3,"result4": $c2 div $c4,"result5": $c2 div $c5, "result6": $c2 div $c6, "result7": $c6 div $c8, "result8": $c6 div [1][1], "result9": $c6/0} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int32/divide_int32.1.query.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int32/divide_int32.1.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int32/divide_int32.1.query.aql index 0026e24..e9adbc2 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int32/divide_int32.1.query.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int32/divide_int32.1.query.aql @@ -24,4 +24,4 @@ let $c4 := int64("-4") let $c5 := float("-5.5f") let $c6 := double("-6.5d") let $c8 := null -return {"result1": $c3/$c1,"result2": $c3/$c2,"result3": $c3/$c3,"result4": $c3/$c4,"result5": $c3/$c5, "result6": $c3/$c6, "result7": $c6/$c8, "result8": $c6/[1][1]} +return {"result1": $c3/$c1,"result2": $c3/$c2,"result3": $c3/$c3,"result4": $c3/$c4,"result5": $c3/$c5, "result6": $c3/$c6, "result7": $c6/$c8, "result8": $c6/[1][1], "result9": $c6/0} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int32/divide_int32.2.query.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int32/divide_int32.2.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int32/divide_int32.2.query.aql index d8ad04a..349211a 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int32/divide_int32.2.query.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int32/divide_int32.2.query.aql @@ -24,4 +24,4 @@ let $c4 := int64("-4") let $c5 := float("-5.5f") let $c6 := double("-6.5d") let $c8 := null -return {"result1": $c3 div $c1,"result2": $c3 div $c2,"result3": $c3 div $c3,"result4": $c3 div $c4,"result5": $c3 div $c5, "result6": $c3 div $c6, "result7": $c6 div $c8, "result8": $c6 div [1][1]} +return {"result1": $c3 div $c1,"result2": $c3 div $c2,"result3": $c3 div $c3,"result4": $c3 div $c4,"result5": $c3 div $c5, "result6": $c3 div $c6, "result7": $c6 div $c8, "result8": $c6 div [1][1], "result9": $c6/0} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int64/divide_int64.1.query.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int64/divide_int64.1.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int64/divide_int64.1.query.aql index b3e11be..b7b99a7 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int64/divide_int64.1.query.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int64/divide_int64.1.query.aql @@ -24,4 +24,4 @@ let $c4 := int64("-4") let $c5 := float("-5.5f") let $c6 := double("-6.5d") let $c8 := null -return {"result1": $c4/$c1,"result2": $c4/$c2,"result3": $c4/$c3,"result4": $c4/$c4,"result5": $c4/$c5, "result6": $c4/$c6, "result7": $c6/$c8, "result8": $c6/[1][1]} +return {"result1": $c4/$c1,"result2": $c4/$c2,"result3": $c4/$c3,"result4": $c4/$c4,"result5": $c4/$c5, "result6": $c4/$c6, "result7": $c6/$c8, "result8": $c6/[1][1], "result9": $c6/0} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int64/divide_int64.2.query.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int64/divide_int64.2.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int64/divide_int64.2.query.aql index 32c72ed..c6694a6 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int64/divide_int64.2.query.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int64/divide_int64.2.query.aql @@ -24,4 +24,4 @@ let $c4 := int64("-4") let $c5 := float("-5.5f") let $c6 := double("-6.5d") let $c8 := null -return {"result1": $c4 div $c1,"result2": $c4 div $c2,"result3": $c4 div $c3,"result4": $c4 div $c4,"result5": $c4 div $c5, "result6": $c4 div $c6, "result7": $c6 div $c8, "result8": $c6 div [1][1]} +return {"result1": $c4 div $c1,"result2": $c4 div $c2,"result3": $c4 div $c3,"result4": $c4 div $c4,"result5": $c4 div $c5, "result6": $c4 div $c6, "result7": $c6 div $c8, "result8": $c6 div [1][1], "result9": $c6/0} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int8/divide_int8.1.query.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int8/divide_int8.1.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int8/divide_int8.1.query.aql index a3cf2ee..afb1488 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int8/divide_int8.1.query.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int8/divide_int8.1.query.aql @@ -24,4 +24,4 @@ let $c4 := int64("-4") let $c5 := float("-5.5f") let $c6 := double("-6.5d") let $c8 := null -return {"result1": $c1/$c1,"result2": $c1/$c2,"result3": $c1/$c3,"result4": $c1/$c4,"result5": $c1/$c5, "result6": $c1/$c6, "result7": $c6/$c8, "result8": $c6/[1][1]} +return {"result1": $c1/$c1,"result2": $c1/$c2,"result3": $c1/$c3,"result4": $c1/$c4,"result5": $c1/$c5, "result6": $c1/$c6, "result7": $c6/$c8, "result8": $c6/[1][1], "result9": $c6/0} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int8/divide_int8.2.query.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int8/divide_int8.2.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int8/divide_int8.2.query.aql index 5adb1b4..07a1910 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int8/divide_int8.2.query.aql +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/numeric/divide_int8/divide_int8.2.query.aql @@ -24,4 +24,4 @@ let $c4 := int64("-4") let $c5 := float("-5.5f") let $c6 := double("-6.5d") let $c8 := null -return {"result1": $c1 div $c1,"result2": $c1 div $c2,"result3": $c1 div $c3,"result4": $c1 div $c4,"result5": $c1 div $c5, "result6": $c1 div $c6, "result7": $c6 div $c8, "result8": $c6 div [1][1]} +return {"result1": $c1 div $c1,"result2": $c1 div $c2,"result3": $c1 div $c3,"result4": $c1 div $c4,"result5": $c1 div $c5, "result6": $c1 div $c6, "result7": $c6 div $c8, "result8": $c6 div [1][1], "result9": $c6/0} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.1.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.1.query.sqlpp index 901be61..31e2399 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.1.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.1.query.sqlpp @@ -18,4 +18,4 @@ */ -{'result1':(double('-6.5d') / tinyint('+1')),'result2':(double('-6.5d') / smallint('2')),'result3':(double('-6.5d') / integer('+3')),'result4':(double('-6.5d') / bigint('-4')),'result5':(double('-6.5d') / float('-5.5f')),'result6':(double('-6.5d') / double('-6.5d')),'result7':(double('-6.5d') / null), 'result8':double('-6.5d') / {}.a}; +{'result1':(double('-6.5d') / tinyint('+1')),'result2':(double('-6.5d') / smallint('2')),'result3':(double('-6.5d') / integer('+3')),'result4':(double('-6.5d') / bigint('-4')),'result5':(double('-6.5d') / float('-5.5f')),'result6':(double('-6.5d') / double('-6.5d')),'result7':(double('-6.5d') / null), 'result8':double('-6.5d') / {}.a, 'result9':double('1') / 0 }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.1.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.1.query.sqlpp index 7dfdcd2..107fed1 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.1.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.1.query.sqlpp @@ -17,4 +17,4 @@ * under the License. */ -{'result1':(float('-5.5f') / tinyint('+1')),'result2':(float('-5.5f') / smallint('2')),'result3':(float('-5.5f') / integer('+3')),'result4':(float('-5.5f') / bigint('-4')),'result5':(float('-5.5f') / float('-5.5f')),'result6':(float('-5.5f') / double('-6.5d')),'result7':(double('-6.5d') / null), 'result8':double('-6.5d') / {}.a}; +{'result1':(float('-5.5f') / tinyint('+1')),'result2':(float('-5.5f') / smallint('2')),'result3':(float('-5.5f') / integer('+3')),'result4':(float('-5.5f') / bigint('-4')),'result5':(float('-5.5f') / float('-5.5f')),'result6':(float('-5.5f') / double('-6.5d')),'result7':(double('-6.5d') / null), 'result8':double('-6.5d') / {}.a, 'result9':double('1') / 0 }; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.1.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.1.query.sqlpp index b0f315d..1e1237d 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.1.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.1.query.sqlpp @@ -17,4 +17,4 @@ * under the License. */ -{'result1':(smallint('2') / tinyint('+1')),'result2':(smallint('2') / smallint('2')),'result3':(smallint('2') / integer('+3')),'result4':(smallint('2') / bigint('-4')),'result5':(smallint('2') / float('-5.5f')),'result6':(smallint('2') / double('-6.5d')),'result7':(double('-6.5d') / null), 'result8':double('-6.5d') / {}.a}; +{'result1':(smallint('2') / tinyint('+1')),'result2':(smallint('2') / smallint('2')),'result3':(smallint('2') / integer('+3')),'result4':(smallint('2') / bigint('-4')),'result5':(smallint('2') / float('-5.5f')),'result6':(smallint('2') / double('-6.5d')),'result7':(smallint('-6') / null), 'result8':smallint('-6') / {}.a, 'result9': smallint('1') / 0 }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.2.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.2.query.sqlpp index cca3dcf..f5bf6fe 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.2.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.2.query.sqlpp @@ -17,4 +17,4 @@ * under the License. */ -{'result1':(smallint('2') div tinyint('+1')),'result2':(smallint('2') div smallint('2')),'result3':(smallint('2') div integer('+3')),'result4':(smallint('2') div bigint('-4')),'result5':(smallint('2') div float('-5.5f')),'result6':(smallint('2') div double('-6.5d')),'result7':(double('-6.5d') div null), 'result8':double('-6.5d') div {}.a}; +{'result1':(smallint('2') div tinyint('+1')),'result2':(smallint('2') div smallint('2')),'result3':(smallint('2') div integer('+3')),'result4':(smallint('2') div bigint('-4')),'result5':(smallint('2') div float('-5.5f')),'result6':(smallint('2') div double('-6.5d')),'result7':(smallint('-6') div null), 'result8':smallint('-6') div {}.a, 'result9': smallint('1') div 0 }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.1.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.1.query.sqlpp index 4a9810d..3e22be1 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.1.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.1.query.sqlpp @@ -18,4 +18,4 @@ */ -{'result1':(integer('+3') / tinyint('+1')),'result2':(integer('+3') / smallint('2')),'result3':(integer('+3') / integer('+3')),'result4':(integer('+3') / bigint('-4')),'result5':(integer('+3') / float('-5.5f')),'result6':(integer('+3') / double('-6.5d')),'result7':(double('-6.5d') / null), 'result8':double('-6.5d') / {}.a}; +{'result1':(integer('+3') / tinyint('+1')),'result2':(integer('+3') / smallint('2')),'result3':(integer('+3') / integer('+3')),'result4':(integer('+3') / bigint('-4')),'result5':(integer('+3') / float('-5.5f')),'result6':(integer('+3') / double('-6.5d')),'result7':(integer('-6') / null), 'result8':integer('-6') / {}.a, 'result9': integer('1') / 0 }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.2.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.2.query.sqlpp index 7ce0f9e..dec8444 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.2.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.2.query.sqlpp @@ -18,4 +18,4 @@ */ -{'result1':(integer('+3') div tinyint('+1')),'result2':(integer('+3') div smallint('2')),'result3':(integer('+3') div integer('+3')),'result4':(integer('+3') div bigint('-4')),'result5':(integer('+3') div float('-5.5f')),'result6':(integer('+3') div double('-6.5d')),'result7':(double('-6.5d') div null), 'result8':double('-6.5d') div {}.a}; +{'result1':(integer('+3') div tinyint('+1')),'result2':(integer('+3') div smallint('2')),'result3':(integer('+3') div integer('+3')),'result4':(integer('+3') div bigint('-4')),'result5':(integer('+3') div float('-5.5f')),'result6':(integer('+3') div double('-6.5d')),'result7':(integer('-6') div null), 'result8':integer('-6') div {}.a, 'result9': integer('1') div 0 }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.1.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.1.query.sqlpp index 5b7d8f5..abdbe08 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.1.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.1.query.sqlpp @@ -17,4 +17,4 @@ * under the License. */ -{'result1':(bigint('-4') / tinyint('+1')),'result2':(bigint('-4') / smallint('2')),'result3':(bigint('-4') / integer('+3')),'result4':(bigint('-4') / bigint('-4')),'result5':(bigint('-4') / float('-5.5f')),'result6':(bigint('-4') / double('-6.5d')),'result7':(double('-6.5d') / null), 'result8':double('-6.5d') / {}.a}; +{'result1':(bigint('-4') / tinyint('+1')),'result2':(bigint('-4') / smallint('2')),'result3':(bigint('-4') / integer('+3')),'result4':(bigint('-4') / bigint('-4')),'result5':(bigint('-4') / float('-5.5f')),'result6':(bigint('-4') / double('-6.5d')),'result7':(bigint('-6') / null), 'result8':bigint('-6') / {}.a, 'result9': bigint('1') / 0 }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.2.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.2.query.sqlpp index 2f850c2..d3bb58c 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.2.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.2.query.sqlpp @@ -17,4 +17,4 @@ * under the License. */ -{'result1':(bigint('-4') div tinyint('+1')),'result2':(bigint('-4') div smallint('2')),'result3':(bigint('-4') div integer('+3')),'result4':(bigint('-4') div bigint('-4')),'result5':(bigint('-4') div float('-5.5f')),'result6':(bigint('-4') div double('-6.5d')),'result7':(double('-6.5d') div null), 'result8':double('-6.5d') div {}.a}; +{'result1':(bigint('-4') div tinyint('+1')),'result2':(bigint('-4') div smallint('2')),'result3':(bigint('-4') div integer('+3')),'result4':(bigint('-4') div bigint('-4')),'result5':(bigint('-4') div float('-5.5f')),'result6':(bigint('-4') div double('-6.5d')),'result7':(bigint('-6') div null), 'result8':bigint('-6') div {}.a, 'result9': bigint('1') div 0 }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.1.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.1.query.sqlpp index dd6917d..a4049ae 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.1.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.1.query.sqlpp @@ -18,4 +18,4 @@ */ -{'result1':(tinyint('+1') / tinyint('+1')),'result2':(tinyint('+1') / smallint('2')),'result3':(tinyint('+1') / integer('+3')),'result4':(tinyint('+1') / bigint('-4')),'result5':(tinyint('+1') / float('-5.5f')),'result6':(tinyint('+1') / double('-6.5d')),'result7':(double('-6.5d') / null), 'result8':double('-6.5d') / {}.a}; +{'result1':(tinyint('+1') / tinyint('+1')),'result2':(tinyint('+1') / smallint('2')),'result3':(tinyint('+1') / integer('+3')),'result4':(tinyint('+1') / bigint('-4')),'result5':(tinyint('+1') / float('-5.5f')),'result6':(tinyint('+1') / double('-6.5d')),'result7':(tinyint('-6') / null), 'result8':tinyint('-6') / {}.a, 'result9': tinyint('1') / 0 }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.2.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.2.query.sqlpp index 5cf4b1b..5d577a9 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.2.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.2.query.sqlpp @@ -18,4 +18,4 @@ */ -{'result1':(tinyint('+1') div tinyint('+1')),'result2':(tinyint('+1') div smallint('2')),'result3':(tinyint('+1') div integer('+3')),'result4':(tinyint('+1') div bigint('-4')),'result5':(tinyint('+1') div float('-5.5f')),'result6':(tinyint('+1') div double('-6.5d')),'result7':(double('-6.5d') div null), 'result8':double('-6.5d') div {}.a}; +{'result1':(tinyint('+1') div tinyint('+1')),'result2':(tinyint('+1') div smallint('2')),'result3':(tinyint('+1') div integer('+3')),'result4':(tinyint('+1') div bigint('-4')),'result5':(tinyint('+1') div float('-5.5f')),'result6':(tinyint('+1') div double('-6.5d')),'result7':(tinyint('-6') div null), 'result8':tinyint('-6') div {}.a, 'result9': tinyint('1') div 0 }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ifinf/ifinf.1.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ifinf/ifinf.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ifinf/ifinf.1.query.sqlpp index 3b395bc..479e290 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ifinf/ifinf.1.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ifinf/ifinf.1.query.sqlpp @@ -40,6 +40,7 @@ from [ [ 18, isnull(ifinf(double("INF"), double("-INF"), [], 2)) ], [ 19, ismissing(if_inf(double("INF"), double("-INF"), missing, 2)) ], [ 20, tostring(ifinf(float("INF"), float("NaN"), 2)) ], - [ 21, if_inf(2, 1/0) ] + [ 21, if_inf(2, 1/0) ], + [ 22, if_inf(1/0, 2) ] ] t order by t[0] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_double/divide_double.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_double/divide_double.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_double/divide_double.1.adm index b371d5b..3f20110 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_double/divide_double.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_double/divide_double.1.adm @@ -1 +1 @@ -{ "result1": -6.5, "result2": -3.25, "result3": -2.1666666666666665, "result4": 1.625, "result5": 1.1818181818181819, "result6": 1.0, "result7": null } +{ "result1": -6.5, "result2": -3.25, "result3": -2.1666666666666665, "result4": 1.625, "result5": 1.1818181818181819, "result6": 1.0, "result7": null, "result9": null } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_float/divide_float.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_float/divide_float.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_float/divide_float.1.adm index ccbe5be..560f641 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_float/divide_float.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_float/divide_float.1.adm @@ -1 +1 @@ -{ "result1": -5.5, "result2": -2.75, "result3": -1.8333334, "result4": 1.375, "result5": 1.0, "result6": 0.8461538461538461, "result7": null } +{ "result1": -5.5, "result2": -2.75, "result3": -1.8333334, "result4": 1.375, "result5": 1.0, "result6": 0.8461538461538461, "result7": null, "result9": null } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int16/divide_int16.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int16/divide_int16.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int16/divide_int16.1.adm index 775745b..0e5450b 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int16/divide_int16.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int16/divide_int16.1.adm @@ -1 +1 @@ -{ "result1": 2.0, "result2": 1.0, "result3": 0.6666666666666666, "result4": -0.5, "result5": -0.36363637, "result6": -0.3076923076923077, "result7": null } +{ "result1": 2.0, "result2": 1.0, "result3": 0.6666666666666666, "result4": -0.5, "result5": -0.36363637, "result6": -0.3076923076923077, "result7": null, "result9": null } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int16/divide_int16.2.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int16/divide_int16.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int16/divide_int16.2.adm index c3d22c3..c25ec67 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int16/divide_int16.2.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int16/divide_int16.2.adm @@ -1 +1 @@ -{ "result1": 2, "result2": 1, "result3": 0, "result4": 0, "result5": -0.36363637, "result6": -0.3076923076923077, "result7": null } \ No newline at end of file +{ "result1": 2, "result2": 1, "result3": 0, "result4": 0, "result5": -0.36363637, "result6": -0.3076923076923077, "result7": null, "result9": null } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int32/divide_int32.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int32/divide_int32.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int32/divide_int32.1.adm index 890417b..96e5114 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int32/divide_int32.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int32/divide_int32.1.adm @@ -1 +1 @@ -{ "result1": 3.0, "result2": 1.5, "result3": 1.0, "result4": -0.75, "result5": -0.54545456, "result6": -0.46153846153846156, "result7": null } +{ "result1": 3.0, "result2": 1.5, "result3": 1.0, "result4": -0.75, "result5": -0.54545456, "result6": -0.46153846153846156, "result7": null, "result9": null } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int32/divide_int32.2.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int32/divide_int32.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int32/divide_int32.2.adm index 788a291..9d8efd9 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int32/divide_int32.2.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int32/divide_int32.2.adm @@ -1 +1 @@ -{ "result1": 3, "result2": 1, "result3": 1, "result4": 0, "result5": -0.54545456, "result6": -0.46153846153846156, "result7": null } \ No newline at end of file +{ "result1": 3, "result2": 1, "result3": 1, "result4": 0, "result5": -0.54545456, "result6": -0.46153846153846156, "result7": null, "result9": null } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int64/divide_int64.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int64/divide_int64.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int64/divide_int64.1.adm index 582b44d..5e8ec2c 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int64/divide_int64.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int64/divide_int64.1.adm @@ -1 +1 @@ -{ "result1": -4.0, "result2": -2.0, "result3": -1.3333333333333333, "result4": 1.0, "result5": 0.72727275, "result6": 0.6153846153846154, "result7": null } +{ "result1": -4.0, "result2": -2.0, "result3": -1.3333333333333333, "result4": 1.0, "result5": 0.72727275, "result6": 0.6153846153846154, "result7": null, "result9": null } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int64/divide_int64.2.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int64/divide_int64.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int64/divide_int64.2.adm index af75a4e..79799d5 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int64/divide_int64.2.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int64/divide_int64.2.adm @@ -1 +1 @@ -{ "result1": -4, "result2": -2, "result3": -1, "result4": 1, "result5": 0.72727275, "result6": 0.6153846153846154, "result7": null } \ No newline at end of file +{ "result1": -4, "result2": -2, "result3": -1, "result4": 1, "result5": 0.72727275, "result6": 0.6153846153846154, "result7": null, "result9": null } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int8/divide_int8.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int8/divide_int8.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int8/divide_int8.1.adm index 591ed6d..4309a1a 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int8/divide_int8.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int8/divide_int8.1.adm @@ -1 +1 @@ -{ "result1": 1.0, "result2": 0.5, "result3": 0.3333333333333333, "result4": -0.25, "result5": -0.18181819, "result6": -0.15384615384615385, "result7": null } +{ "result1": 1.0, "result2": 0.5, "result3": 0.3333333333333333, "result4": -0.25, "result5": -0.18181819, "result6": -0.15384615384615385, "result7": null, "result9": null } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int8/divide_int8.2.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int8/divide_int8.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int8/divide_int8.2.adm index f232ecf..9233e8c 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int8/divide_int8.2.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/divide_int8/divide_int8.2.adm @@ -1 +1 @@ -{ "result1": 1, "result2": 0, "result3": 0, "result4": 0, "result5": -0.18181819, "result6": -0.15384615384615385, "result7": null } \ No newline at end of file +{ "result1": 1, "result2": 0, "result3": 0, "result4": 0, "result5": -0.18181819, "result6": -0.15384615384615385, "result7": null, "result9": null } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/ifinf/ifinf.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/ifinf/ifinf.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/ifinf/ifinf.1.adm index 9f56be4..852db4b 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/ifinf/ifinf.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/ifinf/ifinf.1.adm @@ -19,4 +19,5 @@ [ 18, true ] [ 19, true ] [ 20, "NaN" ] -[ 21, 2 ] \ No newline at end of file +[ 21, 2 ] +[ 22, null ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.1.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.1.ast index a2c5adc..67d0694 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.1.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.1.ast @@ -104,4 +104,15 @@ RecordConstructor [ ] ] ) + ( + LiteralExpr [STRING] [result9] + : + OperatorExpr [ + FunctionCall null.double@1[ + LiteralExpr [STRING] [1] + ] + / + LiteralExpr [LONG] [0] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.1.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.1.ast index 928fc8e..958937c 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.1.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.1.ast @@ -104,4 +104,15 @@ RecordConstructor [ ] ] ) + ( + LiteralExpr [STRING] [result9] + : + OperatorExpr [ + FunctionCall null.double@1[ + LiteralExpr [STRING] [1] + ] + / + LiteralExpr [LONG] [0] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.1.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.1.ast index aa1ac9a..21f2d7f 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.1.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.1.ast @@ -82,8 +82,8 @@ RecordConstructor [ LiteralExpr [STRING] [result7] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int16@1[ + LiteralExpr [STRING] [-6] ] / LiteralExpr [NULL] @@ -93,8 +93,8 @@ RecordConstructor [ LiteralExpr [STRING] [result8] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int16@1[ + LiteralExpr [STRING] [-6] ] / FieldAccessor [ @@ -104,4 +104,15 @@ RecordConstructor [ ] ] ) + ( + LiteralExpr [STRING] [result9] + : + OperatorExpr [ + FunctionCall null.int16@1[ + LiteralExpr [STRING] [1] + ] + / + LiteralExpr [LONG] [0] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.2.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.2.ast index 90fd039..f92b4c2 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.2.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.2.ast @@ -82,8 +82,8 @@ RecordConstructor [ LiteralExpr [STRING] [result7] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int16@1[ + LiteralExpr [STRING] [-6] ] div LiteralExpr [NULL] @@ -93,8 +93,8 @@ RecordConstructor [ LiteralExpr [STRING] [result8] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int16@1[ + LiteralExpr [STRING] [-6] ] div FieldAccessor [ @@ -104,4 +104,15 @@ RecordConstructor [ ] ] ) + ( + LiteralExpr [STRING] [result9] + : + OperatorExpr [ + FunctionCall null.int16@1[ + LiteralExpr [STRING] [1] + ] + div + LiteralExpr [LONG] [0] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.1.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.1.ast index 3b24726..37785cf 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.1.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.1.ast @@ -82,8 +82,8 @@ RecordConstructor [ LiteralExpr [STRING] [result7] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int32@1[ + LiteralExpr [STRING] [-6] ] / LiteralExpr [NULL] @@ -93,8 +93,8 @@ RecordConstructor [ LiteralExpr [STRING] [result8] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int32@1[ + LiteralExpr [STRING] [-6] ] / FieldAccessor [ @@ -104,4 +104,15 @@ RecordConstructor [ ] ] ) + ( + LiteralExpr [STRING] [result9] + : + OperatorExpr [ + FunctionCall null.int32@1[ + LiteralExpr [STRING] [1] + ] + / + LiteralExpr [LONG] [0] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.2.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.2.ast index 05bd4a7..75eb726 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.2.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.2.ast @@ -82,8 +82,8 @@ RecordConstructor [ LiteralExpr [STRING] [result7] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int32@1[ + LiteralExpr [STRING] [-6] ] div LiteralExpr [NULL] @@ -93,8 +93,8 @@ RecordConstructor [ LiteralExpr [STRING] [result8] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int32@1[ + LiteralExpr [STRING] [-6] ] div FieldAccessor [ @@ -104,4 +104,15 @@ RecordConstructor [ ] ] ) + ( + LiteralExpr [STRING] [result9] + : + OperatorExpr [ + FunctionCall null.int32@1[ + LiteralExpr [STRING] [1] + ] + div + LiteralExpr [LONG] [0] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.1.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.1.ast index 1570f6b..22a3401 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.1.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.1.ast @@ -82,8 +82,8 @@ RecordConstructor [ LiteralExpr [STRING] [result7] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int64@1[ + LiteralExpr [STRING] [-6] ] / LiteralExpr [NULL] @@ -93,8 +93,8 @@ RecordConstructor [ LiteralExpr [STRING] [result8] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int64@1[ + LiteralExpr [STRING] [-6] ] / FieldAccessor [ @@ -104,4 +104,15 @@ RecordConstructor [ ] ] ) + ( + LiteralExpr [STRING] [result9] + : + OperatorExpr [ + FunctionCall null.int64@1[ + LiteralExpr [STRING] [1] + ] + / + LiteralExpr [LONG] [0] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.2.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.2.ast index 5e1007a..8f295f3 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.2.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.2.ast @@ -82,8 +82,8 @@ RecordConstructor [ LiteralExpr [STRING] [result7] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int64@1[ + LiteralExpr [STRING] [-6] ] div LiteralExpr [NULL] @@ -93,8 +93,8 @@ RecordConstructor [ LiteralExpr [STRING] [result8] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int64@1[ + LiteralExpr [STRING] [-6] ] div FieldAccessor [ @@ -104,4 +104,15 @@ RecordConstructor [ ] ] ) + ( + LiteralExpr [STRING] [result9] + : + OperatorExpr [ + FunctionCall null.int64@1[ + LiteralExpr [STRING] [1] + ] + div + LiteralExpr [LONG] [0] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.1.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.1.ast index 96b5942..2243ace 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.1.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.1.ast @@ -82,8 +82,8 @@ RecordConstructor [ LiteralExpr [STRING] [result7] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int8@1[ + LiteralExpr [STRING] [-6] ] / LiteralExpr [NULL] @@ -93,8 +93,8 @@ RecordConstructor [ LiteralExpr [STRING] [result8] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int8@1[ + LiteralExpr [STRING] [-6] ] / FieldAccessor [ @@ -104,4 +104,15 @@ RecordConstructor [ ] ] ) + ( + LiteralExpr [STRING] [result9] + : + OperatorExpr [ + FunctionCall null.int8@1[ + LiteralExpr [STRING] [1] + ] + / + LiteralExpr [LONG] [0] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.2.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.2.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.2.ast index 6442d38..f1e7dab 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.2.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.2.ast @@ -82,8 +82,8 @@ RecordConstructor [ LiteralExpr [STRING] [result7] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int8@1[ + LiteralExpr [STRING] [-6] ] div LiteralExpr [NULL] @@ -93,8 +93,8 @@ RecordConstructor [ LiteralExpr [STRING] [result8] : OperatorExpr [ - FunctionCall null.double@1[ - LiteralExpr [STRING] [-6.5d] + FunctionCall null.int8@1[ + LiteralExpr [STRING] [-6] ] div FieldAccessor [ @@ -104,4 +104,15 @@ RecordConstructor [ ] ] ) + ( + LiteralExpr [STRING] [result9] + : + OperatorExpr [ + FunctionCall null.int8@1[ + LiteralExpr [STRING] [1] + ] + div + LiteralExpr [LONG] [0] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java index d8f3f7d..8af1ec7 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java @@ -74,7 +74,6 @@ public class ErrorCode { public static final int INVALID_TYPE_CASTING_MATH_FUNCTION = 31; public static final int REJECT_BAD_CLUSTER_STATE = 32; public static final int REJECT_NODE_UNREGISTERED = 33; - public static final int DIVISION_BY_ZERO = 34; public static final int UNSUPPORTED_MULTIPLE_STATEMENTS = 35; public static final int CANNOT_COMPARE_COMPLEX = 36; public static final int TYPE_MISMATCH_GENERIC = 37; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties index 4adf979..ee88010 100644 --- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties +++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties @@ -69,7 +69,6 @@ 31 = Invalid type-casting math function: %1$s for converting %2$s to %3$s 32 = Cannot execute request, cluster is %1$s 33 = Node is not registered with the CC -34 = Division by zero. 35 = Unsupported multiple statements. 36 = Cannot compare non-primitive values 38 = Input contains different list types http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java index 4afeef1..d2c8269 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java @@ -1210,8 +1210,8 @@ public class BuiltinFunctions { addPrivateFunction(NUMERIC_SUBTRACT, NumericAddSubMulDivTypeComputer.INSTANCE, true); addPrivateFunction(NUMERIC_MULTIPLY, NumericAddSubMulDivTypeComputer.INSTANCE, true); addPrivateFunction(NUMERIC_DIVIDE, NumericDivideTypeComputer.INSTANCE, true); - addPrivateFunction(NUMERIC_MOD, NumericAddSubMulDivTypeComputer.INSTANCE, true); - addPrivateFunction(NUMERIC_DIV, NumericAddSubMulDivTypeComputer.INSTANCE, true); + addPrivateFunction(NUMERIC_MOD, NumericAddSubMulDivTypeComputer.INSTANCE_NULLABLE, true); + addPrivateFunction(NUMERIC_DIV, NumericAddSubMulDivTypeComputer.INSTANCE_NULLABLE, true); addFunction(NUMERIC_ABS, NumericUnaryFunctionTypeComputer.INSTANCE, true); addFunction(NUMERIC_ACOS, NumericDoubleOutputFunctionTypeComputer.INSTANCE, true); addFunction(NUMERIC_ASIN, NumericDoubleOutputFunctionTypeComputer.INSTANCE, true); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java index b311b6e..47ad411 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java @@ -21,6 +21,7 @@ package org.apache.asterix.om.typecomputer.impl; import org.apache.asterix.om.exceptions.IncompatibleTypeException; import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer; import org.apache.asterix.om.types.ATypeTag; +import org.apache.asterix.om.types.AUnionType; import org.apache.asterix.om.types.BuiltinType; import org.apache.asterix.om.types.IAType; import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; @@ -28,10 +29,20 @@ import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression; import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression; public class NumericAddSubMulDivTypeComputer extends AbstractResultTypeComputer { + /** + * For those functions that do not return NULL if both arguments are not NULL + */ + public static final NumericAddSubMulDivTypeComputer INSTANCE = new NumericAddSubMulDivTypeComputer(false); - public static final NumericAddSubMulDivTypeComputer INSTANCE = new NumericAddSubMulDivTypeComputer(); + /** + * For those functions that may return NULL even if both arguments are not NULL (e.g. division by zero) + */ + public static final NumericAddSubMulDivTypeComputer INSTANCE_NULLABLE = new NumericAddSubMulDivTypeComputer(true); - private NumericAddSubMulDivTypeComputer() { + private final boolean nullable; + + private NumericAddSubMulDivTypeComputer(boolean nullable) { + this.nullable = nullable; } @Override @@ -303,6 +314,11 @@ public class NumericAddSubMulDivTypeComputer extends AbstractResultTypeComputer default: throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2); } + + if (nullable && type.getTypeTag() != ATypeTag.ANY) { + type = AUnionType.createNullableType(type); + } + return type; } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDivideTypeComputer.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDivideTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDivideTypeComputer.java index 5e2ebae..c94a22b 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDivideTypeComputer.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDivideTypeComputer.java @@ -22,6 +22,7 @@ package org.apache.asterix.om.typecomputer.impl; import org.apache.asterix.om.exceptions.IncompatibleTypeException; import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer; import org.apache.asterix.om.types.ATypeTag; +import org.apache.asterix.om.types.AUnionType; import org.apache.asterix.om.types.BuiltinType; import org.apache.asterix.om.types.IAType; import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; @@ -232,6 +233,12 @@ public class NumericDivideTypeComputer extends AbstractResultTypeComputer { default: throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2); } + + if (type.getTypeTag() != ATypeTag.ANY) { + // returns NULL if division by 0 + type = AUnionType.createNullableType(type); + } + return type; } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java index b6cec11..746273f 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java @@ -43,6 +43,7 @@ import org.apache.asterix.om.base.AMutableInt32; import org.apache.asterix.om.base.AMutableInt64; import org.apache.asterix.om.base.AMutableInt8; import org.apache.asterix.om.base.AMutableTime; +import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.base.temporal.GregorianCalendarSystem; import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.BuiltinType; @@ -66,32 +67,50 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; @SuppressWarnings("serial") public abstract class AbstractNumericArithmeticEval extends AbstractScalarFunctionDynamicDescriptor { - abstract protected long evaluateInteger(long lhs, long rhs) throws HyracksDataException; + /** + * abstract method for arithmetic operation between two integer values + * + * @param lhs first operand + * @param rhs second operand + * @param result result holder + * @return {@code false} if the result is {@code NULL}, otherwise {@code true} + */ + abstract protected boolean evaluateInteger(long lhs, long rhs, AMutableInt64 result) throws HyracksDataException; - abstract protected double evaluateDouble(double lhs, double rhs) throws HyracksDataException; + /** + * abstract method for arithmetic operation between two floating point values + * + * @param lhs first operand + * @param rhs second operand + * @param result result holder + * @return {@code false} if the result is {@code NULL}, otherwise {@code true} + */ + abstract protected boolean evaluateDouble(double lhs, double rhs, AMutableDouble result) + throws HyracksDataException; /** * abstract method for arithmetic operation between a time instance (date/time/datetime) * and a duration (duration/year-month-duration/day-time-duration) * - * @param chronon - * @param yearMonth - * @param dayTime - * @return - * @throws HyracksDataException + * @param chronon first operand + * @param yearMonth year-month component of the second operand + * @param dayTime day-time component of the second operand + * @param result result holder + * @return {@code false} if the result is {@code NULL}, otherwise {@code true} */ - abstract protected long evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, - boolean isTimeOnly) throws HyracksDataException; + abstract protected boolean evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, + boolean isTimeOnly, AMutableInt64 result) throws HyracksDataException; /** * abstract method for arithmetic operation between two time instances (date/time/datetime) * - * @param chronon0 - * @param chronon1 - * @return - * @throws HyracksDataException + * @param chronon0 first operand + * @param chronon1 second operand + * @param result result holder + * @return {@code false} if the result is {@code NULL}, otherwise {@code true} */ - abstract protected long evaluateTimeInstanceArithmetic(long chronon0, long chronon1) throws HyracksDataException; + abstract protected boolean evaluateTimeInstanceArithmetic(long chronon0, long chronon1, AMutableInt64 result) + throws HyracksDataException; @Override public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) { @@ -153,6 +172,9 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti @SuppressWarnings("rawtypes") private final ISerializerDeserializer durationSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADURATION); + @SuppressWarnings("rawtypes") + private final ISerializerDeserializer nullSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ANULL); @Override @SuppressWarnings("unchecked") @@ -232,58 +254,78 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti double dres; switch (resultType) { case TINYINT: - lres = evaluateInteger(operandsInteger[0], operandsInteger[1]); - if (lres > Byte.MAX_VALUE) { - throw new OverflowException(sourceLoc, getIdentifier()); - } - if (lres < Byte.MIN_VALUE) { - throw new UnderflowException(sourceLoc, getIdentifier()); + if (evaluateInteger(operandsInteger[0], operandsInteger[1], aInt64)) { + lres = aInt64.getLongValue(); + if (lres > Byte.MAX_VALUE) { + throw new OverflowException(sourceLoc, getIdentifier()); + } + if (lres < Byte.MIN_VALUE) { + throw new UnderflowException(sourceLoc, getIdentifier()); + } + aInt8.setValue((byte) lres); + int8Serde.serialize(aInt8, out); + } else { + nullSerde.serialize(ANull.NULL, out); } - aInt8.setValue((byte) lres); - int8Serde.serialize(aInt8, out); break; case SMALLINT: - lres = evaluateInteger(operandsInteger[0], operandsInteger[1]); - if (lres > Short.MAX_VALUE) { - throw new OverflowException(sourceLoc, getIdentifier()); - } - if (lres < Short.MIN_VALUE) { - throw new UnderflowException(sourceLoc, getIdentifier()); + if (evaluateInteger(operandsInteger[0], operandsInteger[1], aInt64)) { + lres = aInt64.getLongValue(); + if (lres > Short.MAX_VALUE) { + throw new OverflowException(sourceLoc, getIdentifier()); + } + if (lres < Short.MIN_VALUE) { + throw new UnderflowException(sourceLoc, getIdentifier()); + } + aInt16.setValue((short) lres); + int16Serde.serialize(aInt16, out); + } else { + nullSerde.serialize(ANull.NULL, out); } - aInt16.setValue((short) lres); - int16Serde.serialize(aInt16, out); break; case INTEGER: - lres = evaluateInteger(operandsInteger[0], operandsInteger[1]); - if (lres > Integer.MAX_VALUE) { - throw new OverflowException(sourceLoc, getIdentifier()); - } - if (lres < Integer.MIN_VALUE) { - throw new UnderflowException(sourceLoc, getIdentifier()); + if (evaluateInteger(operandsInteger[0], operandsInteger[1], aInt64)) { + lres = aInt64.getLongValue(); + if (lres > Integer.MAX_VALUE) { + throw new OverflowException(sourceLoc, getIdentifier()); + } + if (lres < Integer.MIN_VALUE) { + throw new UnderflowException(sourceLoc, getIdentifier()); + } + aInt32.setValue((int) lres); + int32Serde.serialize(aInt32, out); + } else { + nullSerde.serialize(ANull.NULL, out); } - aInt32.setValue((int) lres); - int32Serde.serialize(aInt32, out); break; case BIGINT: - lres = evaluateInteger(operandsInteger[0], operandsInteger[1]); - aInt64.setValue(lres); - int64Serde.serialize(aInt64, out); + if (evaluateInteger(operandsInteger[0], operandsInteger[1], aInt64)) { + int64Serde.serialize(aInt64, out); + } else { + nullSerde.serialize(ANull.NULL, out); + } break; case FLOAT: - dres = evaluateDouble(operandsFloating[0], operandsFloating[1]); - if (dres > Float.MAX_VALUE) { - throw new OverflowException(sourceLoc, getIdentifier()); - } - if (dres < -Float.MAX_VALUE) { - throw new UnderflowException(sourceLoc, getIdentifier()); + if (evaluateDouble(operandsFloating[0], operandsFloating[1], aDouble)) { + dres = aDouble.getDoubleValue(); + if (dres > Float.MAX_VALUE) { + throw new OverflowException(sourceLoc, getIdentifier()); + } + if (dres < -Float.MAX_VALUE) { + throw new UnderflowException(sourceLoc, getIdentifier()); + } + aFloat.setValue((float) dres); + floatSerde.serialize(aFloat, out); + } else { + nullSerde.serialize(ANull.NULL, out); } - aFloat.setValue((float) dres); - floatSerde.serialize(aFloat, out); break; case DOUBLE: - dres = evaluateDouble(operandsFloating[0], operandsFloating[1]); - aDouble.setValue(dres); - doubleSerde.serialize(aDouble, out); + if (evaluateDouble(operandsFloating[0], operandsFloating[1], aDouble)) { + doubleSerde.serialize(aDouble, out); + } else { + nullSerde.serialize(ANull.NULL, out); + } break; } result.set(resultStorage); @@ -298,10 +340,9 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti int offset0 = argPtr0.getStartOffset(); if (rightType == leftType) { - - long leftChronon = 0, rightChronon = 0, dayTime; - + long leftChronon = 0, rightChronon = 0, dayTime = 0; int yearMonth = 0; + boolean yearMonthIsNull = false, dayTimeIsNull = false; switch (leftType) { case DATE: @@ -319,9 +360,14 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti rightChronon = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1); break; case YEARMONTHDURATION: - yearMonth = (int) evaluateTimeInstanceArithmetic( + if (evaluateTimeInstanceArithmetic( AYearMonthDurationSerializerDeserializer.getYearMonth(bytes0, offset0 + 1), - AYearMonthDurationSerializerDeserializer.getYearMonth(bytes1, offset1 + 1)); + AYearMonthDurationSerializerDeserializer.getYearMonth(bytes1, offset1 + 1), + aInt64)) { + yearMonth = (int) aInt64.getLongValue(); + } else { + yearMonthIsNull = true; + } break; case DAYTIMEDURATION: leftChronon = @@ -333,10 +379,18 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti throw new UnsupportedTypeException(sourceLoc, getIdentifier(), bytes1[offset1]); } - dayTime = evaluateTimeInstanceArithmetic(leftChronon, rightChronon); + if (evaluateTimeInstanceArithmetic(leftChronon, rightChronon, aInt64)) { + dayTime = aInt64.getLongValue(); + } else { + dayTimeIsNull = true; + } - aDuration.setValue(yearMonth, dayTime); - durationSerde.serialize(aDuration, out); + if (yearMonthIsNull || dayTimeIsNull) { + nullSerde.serialize(ANull.NULL, out); + } else { + aDuration.setValue(yearMonth, dayTime); + durationSerde.serialize(aDuration, out); + } } else { long chronon = 0, dayTime = 0; @@ -455,29 +509,32 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti bytes1[offset1]); } - chronon = evaluateTimeDurationArithmetic(chronon, yearMonth, dayTime, isTimeOnly); - - switch (resultType) { - case DATE: - if (chronon < 0 && chronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) { - chronon = chronon / GregorianCalendarSystem.CHRONON_OF_DAY - 1; - } else { - chronon = chronon / GregorianCalendarSystem.CHRONON_OF_DAY; - } - aDate.setValue((int) chronon); - serde.serialize(aDate, out); - break; - case TIME: - aTime.setValue((int) chronon); - serde.serialize(aTime, out); - break; - case DATETIME: - aDatetime.setValue(chronon); - serde.serialize(aDatetime, out); - break; - default: - throw new IncompatibleTypeException(sourceLoc, getIdentifier(), bytes0[offset0], - bytes1[offset1]); + if (evaluateTimeDurationArithmetic(chronon, yearMonth, dayTime, isTimeOnly, aInt64)) { + chronon = aInt64.getLongValue(); + switch (resultType) { + case DATE: + if (chronon < 0 && chronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) { + chronon = chronon / GregorianCalendarSystem.CHRONON_OF_DAY - 1; + } else { + chronon = chronon / GregorianCalendarSystem.CHRONON_OF_DAY; + } + aDate.setValue((int) chronon); + serde.serialize(aDate, out); + break; + case TIME: + aTime.setValue((int) chronon); + serde.serialize(aTime, out); + break; + case DATETIME: + aDatetime.setValue(chronon); + serde.serialize(aDatetime, out); + break; + default: + throw new IncompatibleTypeException(sourceLoc, getIdentifier(), bytes0[offset0], + bytes1[offset1]); + } + } else { + nullSerde.serialize(ANull.NULL, out); } } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6b1b52c1/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAddDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAddDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAddDescriptor.java index f64b829..9b8ffeb 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAddDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAddDescriptor.java @@ -18,11 +18,14 @@ */ package org.apache.asterix.runtime.evaluators.functions; +import org.apache.asterix.om.base.AMutableDouble; +import org.apache.asterix.om.base.AMutableInt64; import org.apache.asterix.om.base.temporal.DurationArithmeticOperations; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; import org.apache.asterix.om.types.ATypeTag; +import org.apache.asterix.runtime.exceptions.OverflowException; import org.apache.asterix.runtime.exceptions.UnsupportedTypeException; import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; import org.apache.hyracks.api.exceptions.HyracksDataException; @@ -42,23 +45,34 @@ public class NumericAddDescriptor extends AbstractNumericArithmeticEval { } @Override - protected long evaluateInteger(long x, long y) throws HyracksDataException { - return Math.addExact(x, y); + protected boolean evaluateInteger(long x, long y, AMutableInt64 result) throws HyracksDataException { + try { + long res = Math.addExact(x, y); + result.setValue(res); + return true; + } catch (ArithmeticException e) { + throw new OverflowException(sourceLoc, getIdentifier()); + } } @Override - protected double evaluateDouble(double lhs, double rhs) throws HyracksDataException { - return lhs + rhs; + protected boolean evaluateDouble(double lhs, double rhs, AMutableDouble result) throws HyracksDataException { + double res = lhs + rhs; + result.setValue(res); + return true; } @Override - protected long evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, boolean isTimeOnly) - throws HyracksDataException { - return DurationArithmeticOperations.addDuration(chronon, yearMonth, dayTime, isTimeOnly); + protected boolean evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, boolean isTimeOnly, + AMutableInt64 result) throws HyracksDataException { + long res = DurationArithmeticOperations.addDuration(chronon, yearMonth, dayTime, isTimeOnly); + result.setValue(res); + return true; } @Override - protected long evaluateTimeInstanceArithmetic(long chronon0, long chronon1) throws HyracksDataException { + protected boolean evaluateTimeInstanceArithmetic(long chronon0, long chronon1, AMutableInt64 result) + throws HyracksDataException { throw new UnsupportedTypeException(sourceLoc, getIdentifier(), ATypeTag.SERIALIZED_TIME_TYPE_TAG); } }