Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/23062#discussion_r234859506
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/ScalaReflectionSuite.scala
---
@@ -109,6 +109,35 @@ object TestingUDT {
}
}
+/** An example derived from Twitter/Scrooge codegen for thrift */
+object ScroogeLikeExample {
+ def apply(x: Int): ScroogeLikeExample = new Immutable(x)
+
+ def unapply(_item: ScroogeLikeExample): Option[Int] = Some(_item.x)
+
+ class Immutable(val x: Int) extends ScroogeLikeExample
+}
+
+trait ScroogeLikeExample extends Product1[Int] with Serializable {
+ import ScroogeLikeExample._
+
+ def x: Int
+
+ override def _1: Int = x
+
+ def copy(x: Int = this.x): ScroogeLikeExample = new Immutable(x)
+
+ override def canEqual(other: Any): Boolean =
other.isInstanceOf[ScroogeLikeExample]
+
+ private def _equals(x: ScroogeLikeExample, y: ScroogeLikeExample):
Boolean =
+ x.productArity == y.productArity &&
--- End diff --
Hm, actually that probably won't work any more or less. OK, it's because
there is an Encoder for Product. You can still simplify the equals() and so on
I think, but looks like that's easier than a new Encoder. Or is it sufficient
to test a Seq of a concrete subtype of ScroogeLikeExample?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]