- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Hive truncating char datatype when converting to string
- Labels:
-
Apache Hive
Created 06-07-2017 07:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have noticed an issue in Hive 1.2 where char data is rtrimmed when converted to string. This doesn't occur when converting varchar to string. Is this a bug? or a feature?
select length(cast('abc ' as char(10))), length(cast('abc ' as varchar(10))), length(cast('abc ' as string)); _c0,_c1,_c2 3,7,7
In the above example I would expect the length of the char field to be 10.
Created 06-08-2017 01:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It appears that this is expected behavior.
I discovered a jira pertaining to it here: https://issues.apache.org/jira/browse/HIVE-13865
Created 06-08-2017 12:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like it's a bug, because the Char always fixed length. In this case you have declared it as char(10), even though you have only 3 chars assigned it to, it should not truncate the rest.
Created 06-08-2017 01:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It appears that this is expected behavior.
I discovered a jira pertaining to it here: https://issues.apache.org/jira/browse/HIVE-13865
Created 06-09-2017 10:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good to know this.
