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.