The HiveTableScan operator unwraps string "NULL" (case insensitive) into null values even if the column type is STRING.
To reproduce the bug, we use sql/hive/src/test/resources/groupby_groupingid.txt as test input, copied to /tmp/groupby_groupingid.txt.
We can see that the NULL cells in the original input file are interpreted as string "NULL" in Hive.
Spark SQL session (sbt/sbt hive/console):
As we can see, string "NULL" is interpreted as null values in Spark SQL.