[SPARK-2024] Better type checking for batch serialized RDD