-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-8288][SQL] ScalaReflection can use companion object constructor #23062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e27f933
39979e4
4cba3cc
0074693
83a1987
8c25fd0
04a34c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,36 @@ object TestingUDT { | |
| } | ||
| } | ||
|
|
||
| trait ScroogeLikeExample extends Product1[Int] with java.io.Serializable { | ||
| import ScroogeLikeExample._ | ||
|
|
||
| def _1: Int | ||
|
|
||
| def canEqual(other: Any): Boolean = other.isInstanceOf[ScroogeLikeExample] | ||
|
|
||
| private def _equals(x: ScroogeLikeExample, y: ScroogeLikeExample): Boolean = | ||
| x.productArity == y.productArity && | ||
|
||
| x.productIterator.sameElements(y.productIterator) | ||
|
|
||
| override def equals(other: Any): Boolean = | ||
| canEqual(other) && | ||
| _equals(this, other.asInstanceOf[ScroogeLikeExample]) | ||
|
|
||
| override def hashCode: Int = { | ||
| var hash = _root_.scala.runtime.ScalaRunTime._hashCode(this) | ||
| hash | ||
| } | ||
| override def toString: String = s"ScroogeLikeExample(${_1})" | ||
| } | ||
|
|
||
|
|
||
| object ScroogeLikeExample { | ||
| def apply(x: Int): ScroogeLikeExample = new Immutable(x) | ||
|
|
||
| class Immutable(x: Int) extends ScroogeLikeExample { | ||
| def _1: Int = x | ||
| } | ||
| } | ||
|
|
||
| class ScalaReflectionSuite extends SparkFunSuite { | ||
| import org.apache.spark.sql.catalyst.ScalaReflection._ | ||
|
|
@@ -362,4 +392,11 @@ class ScalaReflectionSuite extends SparkFunSuite { | |
| assert(numberOfCheckedArguments(deserializerFor[(java.lang.Double, Int)]) == 1) | ||
| assert(numberOfCheckedArguments(deserializerFor[(java.lang.Integer, java.lang.Integer)]) == 0) | ||
| } | ||
|
|
||
| test("SPARK-8288") { | ||
drewrobb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| val schema = schemaFor[ScroogeLikeExample] | ||
| assert(schema === Schema( | ||
| StructType(Seq( | ||
| StructField("x", IntegerType, nullable = false))), nullable = true)) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.