HIve Tables and insert data

HI,

 

In this we are simply going to create a table with fields separated by tab “\t” character

This a simple one  ,

 

let’s start , here i will provide only code in hive :-

Sample data :-

2016-01-08T12:27:05.565Z 1452256025 836871
2016-01-08T12:27:12.634Z 1452256033 800798
2016-01-08T12:27:12.632Z 1452256033 795799
2016-01-08T12:27:13.694Z 1452256033 820359
2016-01-08T12:27:15.821Z 1452256036 294141

 

hive> create table userdata(received_at String,time_log String,user_id String)
> row format delimited
> fields terminated by ‘\t’
> stored as textfile
> ;
OK
Time taken: 1.215 seconds

 

hive> load data Local inpath ‘/home/user/Desktop/userdata’ into table userdata;
Loading data to table default.userdata
Table default.userdata stats: [numFiles=1, totalSize=216]
OK
Time taken: 2.157 seconds

 

String FUnctions :-

hive> select substr(received_at,0,10) from userdata;
OK
2016-01-08
2016-01-08
2016-01-08
2016-01-08
2016-01-08

return (start index to length of substring)

hive> select to_date(received_at) from userdata;
OK
2016-01-08
2016-01-08
2016-01-08
2016-01-08
2016-01-08

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s