Tuesday, 6 March 2018

Alter field delimiter in hive

ALTER TABLE temp SET SERDEPROPERTIES ('field.delim' = '|');

example:

create table  temp(a string,b string,c string) row format delimited fields terminated by ',' stored as textfile;

CREATE TABLE `temp`(
  `a` string)
ROW FORMAT DELIMITED
  FIELDS TERMINATED BY ','
STORED AS INPUTFORMAT
  'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
  'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
  'hdfs://hdpdevnn/apps/hive/warehouse/gcw.db/temp'


ALTER TABLE temp SET SERDEPROPERTIES ('field.delim' = '|');


CREATE TABLE `temp`(
  `a` string)
ROW FORMAT DELIMITED
  FIELDS TERMINATED BY '|'
STORED AS INPUTFORMAT
  'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
  'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
  'hdfs://hdpdevnn/apps/hive/warehouse/gcw.db/temp'