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

    https://github.com/apache/spark/pull/12149#discussion_r58586141
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/ScalaReflectionSuite.scala
 ---
    @@ -81,9 +81,43 @@ case class MultipleConstructorsData(a: Int, b: String, 
c: Double) {
       def this(b: String, a: Int) = this(a, b, c = 1.0)
     }
     
    +object TestingUDT {
    +  @SQLUserDefinedType(udt = classOf[NestedStructUDT])
    +  class NestedStruct(val a: Integer, val b: Long, val c: Double)
    +
    +  class NestedStructUDT extends UserDefinedType[NestedStruct] {
    +    override def sqlType: DataType = new StructType()
    +      .add("a", IntegerType, nullable = true)
    +      .add("b", LongType, nullable = false)
    +      .add("c", DoubleType, nullable = false)
    +
    +    override def serialize(n: NestedStruct): Any = {
    +      val row = new 
SpecificMutableRow(sqlType.asInstanceOf[StructType].map(_.dataType))
    +      row.setInt(0, n.a)
    +      row.setLong(1, n.b)
    +      row.setDouble(2, n.c)
    +    }
    +
    +    override def userClass: Class[NestedStruct] = classOf[NestedStruct]
    +
    +    override def deserialize(datum: Any): NestedStruct = datum match {
    +      case row: InternalRow =>
    +        new NestedStruct(row.getInt(0), row.getLong(1), row.getDouble(2))
    +    }
    +  }
    +}
    +
     class ScalaReflectionSuite extends SparkFunSuite {
    --- End diff --
    
    Can we add an end-to-end test using vectors or something?


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