Sqoop – Handle NULL values

By default Sqoop import NULL as null, if you want to change this default configuration you can use following arguments.

While importing data : 

  • –null-string
  • –null-non-string

While exporting data : 

  • –input-null-string
  • –input-null-non-string

Check this example for more clarification : 

sqoop import --driver com.teradata.jdbc.TeraDriver \
--connect "jdbc:teradata://SERVER_IP_ADDRESS/DATABASE=ttmp" \
--username USERNAME \
--password PASSWORD \
--table TABLE_NAME \
--delete-target-dir \
--split-by transaction_id \
--null-string NULL_CHAR_1
--null-non-string NULL_CHAR_2
-m 8

In above example :

  1. –null-string argument represents what should be writtern in HDFS whenever a NULL is identified in column defined as string in relational database.
  2. –null-non-string argument works similar to –null-string argument except that it work on columns defined as non-string in relational database.
Nikhil Aggarwal

Written by Nikhil Aggarwal

Nikhil Aggarwal is an ML engineer with 15+ years in data engineering, distributed systems and cloud. He builds ML and GenAI capabilities for enterprise data platforms, and writes DataForGeeks to explain complex topics through real production problems.

About me · LinkedIn · Newsletter