Support Questions
Find answers, ask questions, and share your expertise

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

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.

View solution in original post

2 REPLIES 2

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

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.

; ;