'Convert string into binary in Hive
I want to match user ids from two tables in Hive. Unfortunately they are stored in different formats. In one table they are binary
whereas in the second table they are stored as string
.
What's the function to convert a string
into binary
in HiveQL?
Solution 1:[1]
A quick solution is to use the binary()
function. Another way to reach the same result is to use the cast()
function. In this second case the code would look like cast(userid as binary)
.
Solution 2:[2]
Use the bin function. eg: bin(user_id)
Solution 3:[3]
cast(cast(id as string) as binary) as id
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Gianluca |
Solution 2 | Monish Chhadwa |
Solution 3 | Simson |