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

    https://github.com/apache/spark/pull/10311#discussion_r48070839
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala 
---
    @@ -740,4 +696,26 @@ trait ScalaReflection {
         assert(methods.length == 1)
         methods.head.getParameterTypes
       }
    +
    +  protected def getConstructorParas(tpe: Type): Seq[(String, Type)] = {
    +    val formalTypeArgs = tpe.typeSymbol.asClass.typeParams
    +    val TypeRef(_, _, actualTypeArgs) = tpe
    +    val constructorSymbol = tpe.member(nme.CONSTRUCTOR)
    +    val params = if (constructorSymbol.isMethod) {
    +      constructorSymbol.asMethod.paramss
    +    } else {
    +      // Find the primary constructor, and use its parameter ordering.
    +      val primaryConstructorSymbol: Option[Symbol] = 
constructorSymbol.asTerm.alternatives.find(
    +        s => s.isMethod && s.asMethod.isPrimaryConstructor)
    +      if (primaryConstructorSymbol.isEmpty) {
    +        sys.error("Internal SQL error: Product object did not have a 
primary constructor.")
    +      } else {
    +        primaryConstructorSymbol.get.asMethod.paramss
    +      }
    +    }
    +
    +    params.flatten.map { p =>
    --- End diff --
    
    I checked, this doesn't work for inner classes. So if a user creates an 
inner product class and use it as part of a `TreeNode`, we can't serialize it 
into JSON.
    
    The problem is not about this `flatten`, but we missing an extra parameter: 
the outer point. I think we can fix it later.


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