[SPARK-3412][SQL]add missing row api

@chenghao-intel assigned this to me, check PR #2284 for previous discussion
Its kinda weird to throw this error for non-primitive types as you can actually return null here.  The check is only to avoid getting back data that looks valid but is not.  For example:

```scala
scala> def getAs[T] = null.asInstanceOf[T]
getAs: [T]=> T

scala> getAs[Int]
res0: Int = 0

scala> getAs[String]
res1: String = null
```