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 import null values from mysql doesn't replace Null

Sqoop import null values from mysql doesn't replace Null

Explorer

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.

1 REPLY 1

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

New Contributor

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