josephxsxn

Hive Casting Char Encoding MainFrame

Jul 7th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.62 KB | None | 0 0
  1. --V1
  2. SELECT decode(encode(DATA,'IBM037'),'IBM273')
  3. FROM casting;
  4.  
  5. --Where ‘data’ is a string in a table… And the data was loaded without conversion as CSV. Hive still reads it as UTF-8 and needs conversion into EBCDIC 037, then decode it using the ‘correct’ codepage. The output appears to be UTF8 as expected.
  6.  
  7.  
  8. --V2
  9. --assuming your input codepage is IBM500
  10. --a is the table you're decoding
  11. --and b has two fields, a country code identifier that matches something in the table you're decoding
  12. --and b.encoding contains things like IBM875
  13. decode(encode(a.cuind_first_name_n,'IBM500'),nvl(b.encoding,'IBM875'))
Add Comment
Please, Sign In to add comment