How does Shuffle Hash Join work in Spark?
January 1, 2021How to properly add jars to a Spark application?
January 6, 2021Converting a String column to an Integer column or converting a column from one type to another is quite simple in Hive. Simply use the cast function to cast the type from one to another.
Here is how you use it – cast(str_column as int)
SELECT col1, cast(str_col as int), col3 from sample_table;
Note that int value is between –2147483648 and 2147483647. You should use bigint If the values in the column are greater than the upper bound of int – cast(string_filed as bigint)
What happens if Hive encountered a string which is not an integer?
If you have a non numerical value (or a non integer) value in a column and you attempted to convert that to an Integer. Hive will be forgiving in that regard. It will simply substitute null and continue processing.