activelearner
activelearner

Reputation: 7745

Hive - Converting a string to bigint

Suppose I have a string like '00321' and I want to convert it into a BIGINT in Hive, how would I do it?

Follow-up question: would the resulting BIGINT value be 321 or 00321?

Upvotes: 10

Views: 49465

Answers (1)

Jeremy Beard
Jeremy Beard

Reputation: 2725

You can use the CAST function to cast your STRING to a BIGINT, like so:

SELECT CAST('00321' AS BIGINT) FROM table;

As a BIGINT it will show on the screen and in delimited text files as 321.

Upvotes: 22

Related Questions