Suppose that a couple hundred Gigs after starting to use HIVE I want to add a column. From the various articles & pages I have seen, I cannot understand the consequences in terms of
Bonus to whoever can answer the same question on structs in a HIVE column.
Yes, we can add column inside a table in Hive using a command: ALTER TABLE table_name ADD COLUMNS (column _name datatypes);
ALTER TABLE table_name ADD COLUMNS (user_id BIGINT); Now to make user_id column as the first column in your table use change column with FIRST clause: ALTER TABLE table_name CHANGE COLUMN user_id user_id BIGINT first; This will move the user_id column to the first position.
Hive expects all the files for one table to use the same delimiter, same compression applied etc. So, you cannot use a Hive table on top of files with multiple formats. Create a view for the UNION of the 3 tables created above.
There is no delete column in hive. however the below commands can work. CREATE TABLE test_change (a int, b int, c int); ALTER TABLE test_change REPLACE COLUMNS (a int, b int);” will remove column 'c' from test_change's schema.
If you add a column to a hive table, only the underlying metastore is updated.
I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With