adarshaU
adarshaU

Reputation: 960

loading data from hdfs into hive results null output in the table

I am trying to load the data from HDFS into hive data warehouse using hive serialization and deserialization query but while retrieving from the table results null output.

Can any one please help me out?

hive>create table stations(usaf string, wban string, name string)
    >row format serde 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
    >with SERDEPROPERTIES(
    >"input.regex" ="(\\d{6}) (\\d{5}) (.{29}) .*"
    >);

hive> load data inpath '/user/cloudera/input-new/ncdc/metadata/stations-fixed-width.txt'
    >into table stations;

While retrieving from table

   hive>select * from stations limit 4;

Results:

   NULL NULL NULL
   NULL NULL NULL
   NULL NULL NULL

Sample data look like this:

010014 99999 SOERSTOKKEN                   NO NO    ENSO  +59783 +005350 +00500

Upvotes: 1

Views: 1478

Answers (1)

vijay kumar
vijay kumar

Reputation: 2049

checked ur regex - it's correct only. Just Add output.format.string in SERDEPROPERTIES as follows :

create table stations(usaf string, wban string, name string)
row format serde 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
with SERDEPROPERTIES(
"input.regex" ="(\\d{6}) (\\d{5}) (.{29}) .*",
"output.format.string" = "%1$s %2$s %3$s"
 )
;

Plz check the execution trace image enter image description here

Upvotes: 1

Related Questions