Support Questions
Find answers, ask questions, and share your expertise

Example for multiple delimiter in hive needed

Highlighted

Example for multiple delimiter in hive needed

Explorer

Hi, I am trying to write a query to create a table which will have more than one delimiter (comman and semi colon for example). I am using MultiDelimitSerde with field.delim serdeproperties. But When I give more than one character it is giving me error. Please help. Below is the command I am writing

 

Below command is working

create table txns(txnid int, custid int, amount double)  row format serde(org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe) with serdeproperites ("field.delim" "[,]") stored as text file;

 

Below is not working

create table txns(txnid int, custid int, amount double)  row format serde(org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe) with serdeproperites ("field.delim" "[,;]") stored as text file;

 

3 REPLIES 3
Highlighted

Re: Example for multiple delimiter in hive needed

Master Guru
Using a semi-colon in the middle of a query string would currently require escaping it. The below form will work instead:

create table txns(txnid int, custid int, amount double) row format serde 'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe' with SERDEPROPERTIES ("field.delim"="[,\;]") stored as textfile;

P.s. When you want to report something as 'not working', please always include a relevant, or the entire error message that you observed.
Highlighted

Re: Example for multiple delimiter in hive needed

Explorer

Hi, Thanks for your reply. THe query worked fine now but I am facing different issue. Please find below

 

Queries executed

create table test1 (f1 int, f2 int, f3 int) row format serde 'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe' with serdeproperties ("field.delim" = "[,\;]") stored as textfile;
load data local inpath '/home/cloudera/Desktop/Ram/test1' overwrite into table test1;

 

data in test1 file

1,2;3

 

When I run select * from test1; I am getting only NULLS

hive> select * from test1;
OK
NULL    NULL    NULL
Time taken: 0.056 seconds, Fetched: 1 row(s)

 

Can you please help me fixing this?

Highlighted

Re: Example for multiple delimiter in hive needed

Explorer

Hi,

    Did anyone had a chance to look at my question above?