Convert Hive String to Number: Quick Guide

To convert a hive string to a number, you can use the CAST function. Here is an example:

Suppose there is a table named test with a column str of string type, and want to convert this column to a numeric type, you can use the following query statement:

SELECT CAST(str AS INT) AS number FROM test;

This will convert all the strings in the str column of the test table to integer type and store the converted results in a new column named number.

bannerAds