user3246020
user3246020

Reputation: 73

Convert Ascii value to Character in hive

I want to convert ascii value to its character in hive.Is there any existing function in a hive (like we have char function in SQL server).Does anyone knows how to achieve this in a hive?

For Example: For 65 , result would be A.

Thanks in advance.

Upvotes: 7

Views: 12125

Answers (2)

Tulsiram Bhardwaj
Tulsiram Bhardwaj

Reputation: 9

This worked for me in Hive:

SELECT CHR(65)
FROM Table_name;

Upvotes: 0

mattinbits
mattinbits

Reputation: 10428

This is possible by combining a few of the built in functions:

Select decode(unhex(hex(65)), 'US-ASCII');

hex changes the int value to a Hexadecimal string, while unhex changes this to binary. then decode interprets the binary as ASCII data.

Upvotes: 7

Related Questions