From 20b5895c9c46a9502bec315fcd2c0ea241bb1b6e 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 -- .../queries/clientnegative/compare_double_bigint.q | 8 -------- .../compare_double_bigint_2.q | 0 .../clientnegative/compare_double_bigint.q.out | 1 - .../clientnegative/compare_double_bigint_2.q.out | 1 - .../clientpositive/llap/compare_double_bigint_2.q.out | 19 +++++++++++++++++++ 7 files changed, 20 insertions(+), 12 deletions(-) delete mode 100644 ql/src/test/queries/clientnegative/compare_double_bigint.q rename ql/src/test/queries/{clientnegative => clientpositive}/compare_double_bigint_2.q (100%) delete mode 100644 ql/src/test/results/clientnegative/compare_double_bigint.q.out delete mode 100644 ql/src/test/results/clientnegative/compare_double_bigint_2.q.out create mode 100644 ql/src/test/results/clientpositive/llap/compare_double_bigint_2.q.out diff --git a/itests/src/test/resources/testconfiguration.properties b/itests/src/test/resources/testconfiguration.properties index b85d71d8ec..f84d1a01d8 100644 --- a/itests/src/test/resources/testconfiguration.properties +++ b/itests/src/test/resources/testconfiguration.properties @@ -486,6 +486,7 @@ minillaplocal.query.files=\ cbo_subq_not_in.q,\ column_table_stats.q,\ column_table_stats_orc.q,\ + compare_double_bigint_2.q,\ constprog_dpp.q,\ current_date_timestamp.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/clientnegative/compare_double_bigint.q deleted file mode 100644 index 435ea9c2c7..0000000000 --- a/ql/src/test/queries/clientnegative/compare_double_bigint.q +++ /dev/null @@ -1,8 +0,0 @@ ---! qt:dataset:src -set hive.strict.checks.bucketing=false; - -set hive.mapred.mode=strict; - --- This should fail until we fix the issue with precision when casting a bigint to a double - -select * from src where cast(1 as bigint) = cast(1.0 as double) limit 10; \ No newline at end of file diff --git a/ql/src/test/queries/clientnegative/compare_double_bigint_2.q b/ql/src/test/queries/clientpositive/compare_double_bigint_2.q similarity index 100% rename from ql/src/test/queries/clientnegative/compare_double_bigint_2.q rename to ql/src/test/queries/clientpositive/compare_double_bigint_2.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/clientnegative/compare_double_bigint_2.q.out b/ql/src/test/results/clientnegative/compare_double_bigint_2.q.out deleted file mode 100644 index a577f0e92d..0000000000 --- a/ql/src/test/results/clientnegative/compare_double_bigint_2.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_2.q.out b/ql/src/test/results/clientpositive/llap/compare_double_bigint_2.q.out new file mode 100644 index 0000000000..16a8079cf3 --- /dev/null +++ b/ql/src/test/results/clientpositive/llap/compare_double_bigint_2.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)