Github user aa8y commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10247#discussion_r47579991
  
    --- 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 --
    
    I considered returning a `Try`. But there are a lot of cases, personally, 
where I don't care about the error since I know the kind of bad data I can 
expect. But that's just me.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to