Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Sqoop Export To Teradata Issue: Exporting \N instead of null

Sqoop Export To Teradata Issue: Exporting \N instead of null

New Contributor

I m trying to sqoop export the data from hive to teradata. If the data in hive is null, its exporting "\N" to teradata database. I have used below two parameters and tried putting as ' ' Or 'null' Or '\\\\N' etc....But every time its exporting only \N.

--input-null-string --input-null-non-string

My requirement is to export null to teradata if there is null in hive. Can someone help me out.

Connector i am using is Teradata Hortonworks connector : --connection manager org.apache.sqoop.teradata.TeradataConn Manager

9 REPLIES 9

Re: Sqoop Export To Teradata Issue: Exporting \N instead of null

Mentor

@Sagar Bonthu you need to escape like so '\\N'

Re: Sqoop Export To Teradata Issue: Exporting \N instead of null

New Contributor

I have tried giving that too like --input-null-string '\\N' --input-null-non-string '\\N' but still exporting \N to teradata but not null.

Re: Sqoop Export To Teradata Issue: Exporting \N instead of null

Mentor

have you checked in Teradata whether it handles nulls properly from your import? @Sagar Bonthu

Re: Sqoop Export To Teradata Issue: Exporting \N instead of null

New Contributor
  1. Sqoop import have no issues Artem Ervits. I am facing this only in Sqoop Export

Re: Sqoop Export To Teradata Issue: Exporting \N instead of null

Mentor

I meant to say to check Teradata properties on handling nulls. @Sagar Bonthu

Re: Sqoop Export To Teradata Issue: Exporting \N instead of null

Mentor

@Sagar Bonthu has this been resolved? Can you post your solution or accept best answer?

Re: Sqoop Export To Teradata Issue: Exporting \N instead of null

Mentor

@Sagar Bonthu

have you seen this? You can define your own NULL types in Hive when you create tables, so in your case, define NULL type that Teradata can understand. LINK.

Row Format, Storage Format, and SerDe

You can create tables with a custom SerDe or using a native SerDe. A native SerDe is used if ROW FORMAT is not specified or ROW FORMAT DELIMITED is specified. You can use the DELIMITED clause to read delimited files, and you can enable escaping for the delimiter characters by using the 'ESCAPED BY' clause (such as ESCAPED BY '\') – escaping is needed if you want to work with data that can contain these delimiter characters. A custom NULL format can also be specified using the 'NULL DEFINED AS' clause (default is '\N'). Use the SERDE clause to create a table with a custom SerDe.

Re: Sqoop Export To Teradata Issue: Exporting \N instead of null

New Contributor

Hi my friend,

I was with the same problem (using hive and sqoop to export) and i resolved putting that argument on hive create table:

NULL DEFINED AS "null"

Hug, Rafael

Re: Sqoop Export To Teradata Issue: Exporting \N instead of null

New Contributor

you can use this : --input-null-string "\\\\N" --input-null-non-string "\\\\N"