Github user marmbrus commented on a diff in the pull request: https://github.com/apache/spark/pull/10247#discussion_r47580230 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala --- @@ -325,6 +341,14 @@ trait Row extends Serializable { def getAs[T](i: Int): T = get(i).asInstanceOf[T] /** + * Returns the Optional value of a given fieldName. + * If the value is null or if it cannot be cast to the requested type, None is returned. None is + * also returned if either the schema is not defined or else the given fieldName does not exist + * in the schema. + */ + def getAsOpt[T](fieldName: String): Option[T] = None --- End diff -- Yeah, but this is data coming out of Spark SQL, so the type will always be correct. Bad data would not make it this far.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org