What is the difference between reduceByKey and aggregateByKey in Spark?
April 19, 2021How to fix “Could not locate executable winutils.exe” issue in Hadoop?
April 23, 2021Let’s say you created a table with one of the columns as STRING and after a couple of days you realized the column should actually be an INT. It is quite easy to alter the type of the column in Hive.
Solution
Let’s say the e_id column in the employee table is currently a STRING and we want to change it to an INT.
Use the ALTER command on the table with the CHANGE clause.
The ALTER command can also be used to change the column name. If you are not changing the column name, specify the same column name for both old and new column names.
Here we are not changing the column names so we specify e_id for both old and new column names followed by the data type.
ALTER TABLE <table-name> CHANGE <old-col-name> <new-col-name> <data-type>; ALTER TABLE employee CHANGE e_id e_id INT;
Note that this changes the metadata of the table and not make any changes to the data.