Impala Public Jenkins has submitted this change and it was merged. Change subject: IMPALA-4370: Divide and modulo result types for DECIMAL version V2 ......................................................................
IMPALA-4370: Divide and modulo result types for DECIMAL version V2 Implement the new DECIMAL return type rules for divide and modulo expressions, active when query option DECIMAL_V2=1. See the comment in the code for more details. A couple of examples that show why new return type rules for divide are desirable. For modulo, the return types are actually equivalent, though the rules are expressed differently to have consistency with how precision fixups are handled for each version. DECIMAL Version 1: +-------------------------------------------------------+ | cast(1 as decimal(20,0)) / cast(3 as decimal(20,0)) | +-----------------------------------------------------+ | 0 | +-------------------------------------------------------+ DECIMAL Version 2: +-------------------------------------------------------+ | cast(1 as decimal(20,0)) / cast(3 as decimal(20,0)) | +-----------------------------------------------------+ | 0.333333333333333333 | +-------------------------------------------------------+ DECIMAL Version 1: +-------------------------------------------------------+ | cast(1 as decimal(6,0)) / cast(0.1 as decimal(38,38)) | +-------------------------------------------------------+ | NULL | +-------------------------------------------------------+ WARNINGS: UDF WARNING: Expression overflowed, returning NULL DECIMAL Version 2: +-------------------------------------------------------+ | cast(1 as decimal(6,0)) / cast(0.1 as decimal(38,38)) | +-------------------------------------------------------+ | 10.000000 | +-------------------------------------------------------+ Change-Id: I83e7f7787edfa4b4bddc25945090542a0e90881b Reviewed-on: http://gerrit.cloudera.org:8080/5952 Reviewed-by: Dan Hecht <[email protected]> Tested-by: Impala Public Jenkins --- M be/src/exprs/expr-test.cc M be/src/runtime/decimal-value.inline.h M be/src/testutil/impalad-query-executor.h M fe/src/main/java/org/apache/impala/analysis/ArithmeticExpr.java M fe/src/main/java/org/apache/impala/analysis/FunctionCallExpr.java M fe/src/main/java/org/apache/impala/analysis/TypesUtil.java M fe/src/main/java/org/apache/impala/catalog/ScalarType.java M fe/src/main/java/org/apache/impala/catalog/Type.java A testdata/workloads/functional-query/queries/QueryTest/decimal-exprs.test M testdata/workloads/functional-query/queries/QueryTest/decimal.test M tests/query_test/test_decimal_queries.py 11 files changed, 374 insertions(+), 148 deletions(-) Approvals: Impala Public Jenkins: Verified Dan Hecht: Looks good to me, approved -- To view, visit http://gerrit.cloudera.org:8080/5952 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: merged Gerrit-Change-Id: I83e7f7787edfa4b4bddc25945090542a0e90881b Gerrit-PatchSet: 15 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: Dan Hecht <[email protected]> Gerrit-Reviewer: Dan Hecht <[email protected]> Gerrit-Reviewer: Impala Public Jenkins Gerrit-Reviewer: Marcel Kornacker <[email protected]> Gerrit-Reviewer: Michael Ho <[email protected]> Gerrit-Reviewer: Zach Amsden <[email protected]>
