Reply
Explorer
Posts: 33
Registered: ‎01-30-2017

Sqoop import null values from mysql doesn't replace Null

In mysql there is a table with some columns have null values. I want to sqoop import the table to hive. When I do sqoop import I am getting all null values in the columns that have null in the mysql table.

 

I am doing the following

   

   sqoop import --connect jdbc:xxxxxx --username xxxx --password xxxx \
    --query "select * from hive_db.xxxx where \$CONDITIONS" --null-string '' \
    --null-non-string '' -m 1 --hive-import --hive-database hivedatabase \
    --hive-table table --as-parquetfile --create-hive-table --target-dir /user/hive/warehouse/hivedatabase.db/table

 

But I am still getting the hive columns as Null intsead of empty

Why is this happening? How do I get the desired result.

Highlighted
New Contributor
Posts: 1
Registered: ‎09-18-2018

Re: Sqoop import null values from mysql doesn't replace Null

Hello Sanjeev

 

Please use the below query, this will replace the null columns to coressponding NA(if its a string column) or to -1(if its a non-string column)

 

 sqoop import --connect jdbc:xxxxxx --username xxxx --password xxxx \
    --query "select * from hive_db.xxxx where \$CONDITIONS" --null-string "NA" '' \
    --null-non-string -1 '' -m 1 --hive-import --hive-database hivedatabase \
    --hive-table table --as-parquetfile --create-hive-table --target-dir /user/hive/warehouse/hivedatabase.db/table

 

 

Announcements