Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Inverse of function bin

SOLVED Go to solution

Inverse of function bin

Contributor

Hello,

 

I have a string like "0010011" and I want to convert it to int. It is the inverse of function

bin(a int)

I think

cast("0010011" as binary) 

Doesn't exists

How can I do that?

 

Regards,

Joaquín Silva

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Inverse of function bin

Expert Contributor

I just saw this thread after commenting on the Jira. Would "conv()" be a suitable workaround here?

 

select conv('100010', 2, 10);
+-----------------------+
| conv('100010', 2, 10) |
+-----------------------+
| 34                    |
+-----------------------+
Fetched 1 row(s) in 0.24s

 

More information on conv() can be found in the Impala documentation.

 

 Edit: To make things complete, the Jira is IMPALA-4968.

2 REPLIES 2

Re: Inverse of function bin

Master Collaborator

Hi Joaqin,

 

reasonable request. Could you please file a JIRA for this new feature?

It woud be great if someone from the community can pick this up!

 

Thanks.


Alex

Highlighted

Re: Inverse of function bin

Expert Contributor

I just saw this thread after commenting on the Jira. Would "conv()" be a suitable workaround here?

 

select conv('100010', 2, 10);
+-----------------------+
| conv('100010', 2, 10) |
+-----------------------+
| 34                    |
+-----------------------+
Fetched 1 row(s) in 0.24s

 

More information on conv() can be found in the Impala documentation.

 

 Edit: To make things complete, the Jira is IMPALA-4968.