Sqoop --null-string and --null-non-string

In MYSQL I have a table departmentswhich has 9 rows and one of the department_id has null value in its department_name.

I ran the following command :

sqoop-import --connect “jdbc:mysql://nn01.itversity.com:3306/retail_import”
–username retail_dba
–password itversity
–table rkathiravan_department_rev
–target-dir “/user/rkathiravan/rkathiravan_sqoop_import/rkathiravan_department_rev”
–delete-target-dir
-m 1
–outdir javafiles
–fields-terminated-by ‘|’
–lines-terminated-by ‘\n’
–null-string nvl
–null-non-string -1
i dont see nvl on the department name after i import. what could be the error.?
table before importing
department_id | department_name |
±--------------±----------------+
| 1 | phy |
| 2 | chemistry |
| 3 | maths2 |
| 4 | bio |
| 5 | geo |
| 6 | his |
| 7 | null |
| 8 | maths2 |
| 9 | rev
result after importing
[rkathiravan@gw01 ~]$ hadoop fs -cat /user/rkathiravan/rkathiravan_sqoop_import/rkathiravan_department_rev/part*
1|phy
2|chemistry
3|maths2
4|bio
5|geo
6|his
7|null
8|maths2
9|rev

In sql “| 7 | null |” ,here “null” is a string , so on import it doesn’t make the change.
try make it empty ( “| 7 | |” - which intern denotes it has null values ), then you can see the “nvl” on importing .

1 Like

But Durga sir explained With null . I have tried in another examples it worked for me. But now for this example it’s not working. I don’t know the reason. Can someone help!!!