0
votes

I have loaded a huge table from SQL Server onto Hive. The mistake I made is I created the table as a Internal table in HIVE. Can anyone suggest any hack so that I can alter the table structure , without dropping the data. The data is huge and I cant afford to export the data out of source again.

The problem right now, is that since the column orders don't match the SQL server table, a lot of columns display NULL.

Any help will be highly appreciated.

1

1 Answers

0
votes

I do not see any problem to use an Alter Table on a internal table. (https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-AlterTable/Partition/Column)

Another - but not recommended - option would be to open your hive metastore(HCatalog) and apply the changes there. Hive reads out the schema information from a relational database (configured during the Hadoop setup, default is MySQL). In this MySQL you can try to change some settings. However, this is not recommended as with a mistake, you can screw your whole Hive databases.

The safest way is creating a new table and using the existing as a source

create table new_table
as
select
[...]
from existing_table