This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new ae89034eb42 HIVE-27885 : Cast decimal from string with space without 
digits before dot returns NULL (#4876)
ae89034eb42 is described below

commit ae89034eb424b3a51b001ac1df8781c4e507b9e0
Author: Naresh P R <[email protected]>
AuthorDate: Wed Nov 22 09:11:31 2023 -0800

    HIVE-27885 : Cast decimal from string with space without digits before dot 
returns NULL (#4876)
---
 ql/src/test/queries/clientpositive/cast2.q                       | 3 +++
 ql/src/test/results/clientpositive/llap/cast2.q.out              | 9 +++++++++
 .../org/apache/hadoop/hive/common/type/FastHiveDecimalImpl.java  | 1 +
 3 files changed, 13 insertions(+)

diff --git a/ql/src/test/queries/clientpositive/cast2.q 
b/ql/src/test/queries/clientpositive/cast2.q
index 12228befb56..bd4835c6280 100644
--- a/ql/src/test/queries/clientpositive/cast2.q
+++ b/ql/src/test/queries/clientpositive/cast2.q
@@ -3,3 +3,6 @@ select cast('1' as tinyint), cast('1' as smallint), cast('1' as 
int), cast('1' a
 
 -- Check that leading/trailing space is handled consistently for numeric types
 select cast(' 1 ' as tinyint), cast(' 1 ' as smallint), cast(' 1 ' as int), 
cast(' 1 ' as bigint), cast(' 1 ' as float), cast(' 1 ' as double), cast(' 1 ' 
as decimal(10,2));
+
+-- Decimal cast with spaces/without digits before dot & only dot.
+select cast(".0000 " as decimal(8,4)), cast(" .0000" as decimal(8,4)), cast(" 
.0000  " as decimal(8,4)), cast("." as decimal(8,4)), cast(".  " as 
decimal(8,4)), cast("  .  " as decimal(8,4)), cast(".00 00 " as decimal(8,4));
diff --git a/ql/src/test/results/clientpositive/llap/cast2.q.out 
b/ql/src/test/results/clientpositive/llap/cast2.q.out
index d5d6bbac2c6..e85f4945488 100644
--- a/ql/src/test/results/clientpositive/llap/cast2.q.out
+++ b/ql/src/test/results/clientpositive/llap/cast2.q.out
@@ -16,3 +16,12 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: _dummy_database@_dummy_table
 #### A masked pattern was here ####
 1      1       1       1       1.0     1.0     1.00
+PREHOOK: query: select cast(".0000 " as decimal(8,4)), cast(" .0000" as 
decimal(8,4)), cast(" .0000  " as decimal(8,4)), cast("." as decimal(8,4)), 
cast(".  " as decimal(8,4)), cast("  .  " as decimal(8,4)), cast(".00 00 " as 
decimal(8,4))
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(".0000 " as decimal(8,4)), cast(" .0000" as 
decimal(8,4)), cast(" .0000  " as decimal(8,4)), cast("." as decimal(8,4)), 
cast(".  " as decimal(8,4)), cast("  .  " as decimal(8,4)), cast(".00 00 " as 
decimal(8,4))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+0.0000 0.0000  0.0000  NULL    NULL    NULL    NULL
diff --git 
a/storage-api/src/java/org/apache/hadoop/hive/common/type/FastHiveDecimalImpl.java
 
b/storage-api/src/java/org/apache/hadoop/hive/common/type/FastHiveDecimalImpl.java
index f9466d7c9ca..65429e10b85 100644
--- 
a/storage-api/src/java/org/apache/hadoop/hive/common/type/FastHiveDecimalImpl.java
+++ 
b/storage-api/src/java/org/apache/hadoop/hive/common/type/FastHiveDecimalImpl.java
@@ -443,6 +443,7 @@ public class FastHiveDecimalImpl extends FastHiveDecimal {
           }
           break;
         }
+        haveInteger = true;
         digitValue = work - BYTE_DIGIT_ZERO;
         if (digitNum == 0) {
 

Reply via email to