Apsara Thankappan
Apsara Thankappan

Reputation: 9

how to remove hive new line character from the data stored in AVRO format

I had a data saved in Azure blob in AVRO format. I need to remove hive new line characters from the data while executing the select query. The output of the hive select query should not contain hive new line character. I am currently using regexp_replace({0}, '\t|\r\n|\n', ' ') to replace the new line character with space. But, its not working as per the need.

Upvotes: 0

Views: 9369

Answers (2)

Hemanth meka
Hemanth meka

Reputation: 193

You need to replace the newline char present in that specific column with some other char, like this

select regexp_replace(col_which_has_new_line,"\n","") from tbl;

Upvotes: 3

Apsara Thankappan
Apsara Thankappan

Reputation: 9

Suppose if I had an Address hive table with columns AddressId, FullAddress, UpdatedDate and UpdatedBy. Now the records already present is like the below:

AddressId FullAddress UpdatedDate UpdatedBy 123 Apartment 601, 2015-01-22 XYZ
XYZ Street,
XYZ

After selecting the data from hive table, I need the out shown below:

AddressId FullAddress UpdatedDate UpdatedBy 123 Apartment 601,XYZ Street,XYZ 2015-01-22 XYZ

Thanks.

Upvotes: 0

Related Questions