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

    https://github.com/apache/spark/pull/9649#discussion_r45027742
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala ---
    @@ -328,7 +328,8 @@ object StructType extends AbstractDataType {
       def apply(fields: Seq[StructField]): StructType = 
StructType(fields.toArray)
     
       def apply(fields: java.util.List[StructField]): StructType = {
    -    StructType(fields.toArray.asInstanceOf[Array[StructField]])
    +    import scala.collection.JavaConverters._
    +    StructType(fields.asScala)
    --- End diff --
    
    `DataTypes.createStructType` works well because it use `fields.toArray(new 
StructField[0])`. However, I think it's bad to create an empty `StructField` 
array every time we call that method.
    You remind me that we should also update `DataTypes.createStructType` to 
use this `apply` method.



---
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