From 2b15fc6c1c2415e68578b2c91f6bf4b7ef735bcc Mon Sep 17 00:00:00 2001 From: Ashutosh Chauhan Date: Sun, 20 May 2018 12:18:47 -0700 Subject: [PATCH] HIVE-19619 : Allow comparisons between doubles and bigints --- .../src/test/resources/testconfiguration.properties | 1 + .../hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java | 2 -- .../compare_double_bigint.q | 0 .../clientnegative/compare_double_bigint.q.out | 1 - .../clientpositive/llap/compare_double_bigint.q.out | 19 +++++++++++++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) rename ql/src/test/queries/{clientnegative => clientpositive}/compare_double_bigint.q (100%) delete mode 100644 ql/src/test/results/clientnegative/compare_double_bigint.q.out create mode 100644 ql/src/test/results/clientpositive/llap/compare_double_bigint.q.out diff --git a/itests/src/test/resources/testconfiguration.properties b/itests/src/test/resources/testconfiguration.properties index b85d71d8ec..57e4730b28 100644 --- a/itests/src/test/resources/testconfiguration.properties +++ b/itests/src/test/resources/testconfiguration.properties @@ -116,6 +116,7 @@ minillaplocal.shared.query.files=alter_merge_2_orc.q,\ cbo_views.q,\ cbo_windowing.q,\ column_names_with_leading_and_trailing_spaces.q,\ + compare_double_bigint.q,\ constprog_dpp.q,\ constprog_semijoin.q,\ correlationoptimizer1.q,\ diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java index 31bd290c6e..961eea292b 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java @@ -250,8 +250,6 @@ public static ExprNodeGenericFuncDesc newInstance(GenericUDF genericUDF, console.printError("WARNING: Comparing a bigint and a string may result in a loss of precision."); } else if ((oiTypeInfo0.equals(TypeInfoFactory.doubleTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.longTypeInfo)) || (oiTypeInfo0.equals(TypeInfoFactory.longTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.doubleTypeInfo))) { - String error = StrictChecks.checkTypeSafety(conf); - if (error != null) throw new UDFArgumentException(error); console.printError("WARNING: Comparing a bigint and a double may result in a loss of precision."); } } diff --git a/ql/src/test/queries/clientnegative/compare_double_bigint.q b/ql/src/test/queries/clientpositive/compare_double_bigint.q similarity index 100% rename from ql/src/test/queries/clientnegative/compare_double_bigint.q rename to ql/src/test/queries/clientpositive/compare_double_bigint.q diff --git a/ql/src/test/results/clientnegative/compare_double_bigint.q.out b/ql/src/test/results/clientnegative/compare_double_bigint.q.out deleted file mode 100644 index a577f0e92d..0000000000 --- a/ql/src/test/results/clientnegative/compare_double_bigint.q.out +++ /dev/null @@ -1 +0,0 @@ -FAILED: SemanticException Line 0:-1 Wrong arguments '1.0': Unsafe compares between different types are disabled for safety reasons. If you know what you are doing, please set hive.strict.checks.type.safety to false and make sure that hive.mapred.mode is not set to 'strict' to proceed. Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features. diff --git a/ql/src/test/results/clientpositive/llap/compare_double_bigint.q.out b/ql/src/test/results/clientpositive/llap/compare_double_bigint.q.out new file mode 100644 index 0000000000..16a8079cf3 --- /dev/null +++ b/ql/src/test/results/clientpositive/llap/compare_double_bigint.q.out @@ -0,0 +1,19 @@ +WARNING: Comparing a bigint and a double may result in a loss of precision. +PREHOOK: query: select * from src where cast(1 as bigint) = cast(1.0 as double) limit 10 +PREHOOK: type: QUERY +PREHOOK: Input: default@src +#### A masked pattern was here #### +POSTHOOK: query: select * from src where cast(1 as bigint) = cast(1.0 as double) limit 10 +POSTHOOK: type: QUERY +POSTHOOK: Input: default@src +#### A masked pattern was here #### +238 val_238 +86 val_86 +311 val_311 +27 val_27 +165 val_165 +409 val_409 +255 val_255 +278 val_278 +98 val_98 +484 val_484 -- 2.15.1 (Apple Git-101)