I want to filter the Null value which selected from Cassandra.
Here is my query:
scala> var rdd = sc.cassandraTable("keyspace", "table").select("month", "timetag", "name").where("month = ?", "201704")
scala> var data = rdd.filter(_.getString("name") != null)
If I use getString("xxx") compare to null, it will show
"java.lang.NullPointerException: Unexpected null value of column 2. Use get[Option[...]] to receive null values."
After that, I tried to use getStringOption to compare.
scala> var rdd = sc.cassandraTable("keyspace", "table").select("month", "timetag", "name").where("month = ?", "201704")
scala> var data = rdd.filter(_.getStringOption("name") != null)
This time, it didn't show any error message. But the data is not filtered. The null data is still there.
Does anyone know what is different between getString and getStringOption? Or is there any other way I can compare the data from Cassandra is null?
Thanks a lot!