Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIVE-27885 : Cast decimal from string with space without digits before dot returns NULL #4876

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ql/src/test/queries/clientpositive/cast2.q
Original file line number Diff line number Diff line change
Expand Up @@ -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));
9 changes: 9 additions & 0 deletions ql/src/test/results/clientpositive/llap/cast2.q.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ public static boolean fastSetFromBytes(byte[] bytes, int offset, int length, boo
}
break;
}
haveInteger = true;
digitValue = work - BYTE_DIGIT_ZERO;
if (digitNum == 0) {

Expand Down