Loading Data into Hive



0

Hi,

I am practicing Hive and was trying to load data from a Formatted Text file into Hive Table. The table creation script and load command is as under:

use vivek;

drop table product_sales;

create table product_sales (
prod_id int comment 'This is a Product Code',
prod_name string comment 'Product Name',
cust_id int comment 'Customer ID',
first_name string comment 'Customer First Name',
last_name string comment 'Customer Second Name',
cust_city string comment 'Customer City Name',
cust_province string comment 'Customer Province',
time_id string comment 'Product Sales data',
quantity_sold int,
amount_sold float)
row format delimited fields terminated by '|'
stored as textfile;


load data local inpath '/home/cloudera/Product_Sales_data.txt' into table product_sales;

I have attached the text file as well. The data into prod_id, cust_id and quantity_sold is inserted as a NULL. Need assistance here. What are the different ways by way of which I can load the data efficiently into this table and the column data has proper values ?

Regards

Vivek



3 Answer(s)


0

Hi Vivek,

I checked the codes, it is running fine. I was able to get the output.
Please try again and share the output screenshot in case you are still not able to generate the output.

 

Hope this helps.

Thanks.


0

Hi Abhijeet,

I am uploading the create table, load data and select statement output. The INT columns are populated as NULLS. I could fix it by declaring each of these INT as STRING, but wanted to check the issue when populating a fixed formatted output into an INT column and whether I am doing something wrong.

Regards

Vivek



0

Any update on this ? 

Regards

Vivek

Your Answer

Click on this code-snippet-icon icon to add code snippet.

Upload Files (Maximum image file size - 1.5 MB, other file size - 10 MB, total size - not more than 50 MB)

Email
Password