Hive - Load Data
Once the internal table has been created, the next step is to load the data into it. So, in Hive, we can easily load data from any file to the database.
- Let's load the data of the file into the database by using the following command: -
Here, emp_details is the file name that contains the data.
- Now, we can use the following command to retrieve the data from the database.
- If we want to add more data into the current database, execute the same query again by just updating the new file name.
- Let's check the data of an updated table: -
- In Hive, if we try to load unmatched data (i.e., one or more column data doesn't match the data type of specified table columns), it will not throw any exception. However, it stores the Null value at the position of unmatched tuple.
- Let's add one more file to the current table. This file contains the unmatched data.
Here, the third column contains the data of string type, and the table allows the float type data. So, this condition arises in an unmatched data situation.
- Now, load the data into the table.
Here, data loaded successfully.
- Let's fetch the records of the table.
Here, we can see the Null values at the position of unmatched data.