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

    https://github.com/apache/spark/pull/22527#discussion_r222185482
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala ---
    @@ -1098,16 +1098,24 @@ object SQLContext {
           data: Iterator[_],
           beanClass: Class[_],
           attrs: Seq[AttributeReference]): Iterator[InternalRow] = {
    -    val extractors =
    -      
JavaTypeInference.getJavaBeanReadableProperties(beanClass).map(_.getReadMethod)
    -    val methodsToConverts = extractors.zip(attrs).map { case (e, attr) =>
    -      (e, CatalystTypeConverters.createToCatalystConverter(attr.dataType))
    +    def createStructConverter(cls: Class[_], fieldTypes: 
Iterator[DataType]): Any => InternalRow = {
    +      val methodConverters =
    +        
JavaTypeInference.getJavaBeanReadableProperties(cls).iterator.zip(fieldTypes)
    +          .map { case (property, fieldType) =>
    +            val method = property.getReadMethod
    +            method -> createConverter(method.getReturnType, fieldType)
    +          }.toArray
    +      value => new GenericInternalRow(
    --- End diff --
    
    We should check whether the `value` is `null` or not? Also could you add a 
test for the case?


---

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

Reply via email to