Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21732#discussion_r235273262
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/encoders/ExpressionEncoder.scala
 ---
    @@ -257,6 +251,11 @@ case class ExpressionEncoder[T](
        */
       def isSerializedAsStruct: Boolean = 
objSerializer.dataType.isInstanceOf[StructType]
     
    +  /**
    +   * Returns true if the type `T` is `Option`.
    +   */
    +  def isOptionType: Boolean = 
classOf[Option[_]].isAssignableFrom(clsTag.runtimeClass)
    --- End diff --
    
    regarding maintainability, I think it's better to add a 
    ```
    // maybe there is a better naming
    def isSerializedAsStructForTopLevel: Boolean = {
      isSerializedAsStruct && isOption
    }
    ```
    
    The benefit is, when people call `isSerializedAsStruct`, they will see this 
similar method and think carefully which one he should use. Otherwise, people 
may miss to check `isOptionType` easily.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to