pyspark hive - Insert NULL as DB null through text file

765 Views Asked by At

While inserting text file from pyspark shell to hive table.

NULL values treating as string in table.

If i query hive table, records can be retried only with filter condition = 'NULL' rather than is null.

Can any one suggest how to insert data as DB NULLS in table

1

There are 1 best solutions below

0
Shubham Jain On BEST ANSWER

Check if your spark dataframe is having null or None. And while writing to the hive table set the nullValue option as

df.write.option('nullValue', None).saveAsTable(path)

This will solve your issue.