Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,11 @@ trait ScalaReflection {
}

protected def constructParams(tpe: Type): Seq[Symbol] = {
val constructorSymbol = tpe.member(termNames.CONSTRUCTOR)
val constructorSymbol = tpe.member(termNames.CONSTRUCTOR) match {
case NoSymbol =>
tpe.typeSymbol.asClass.companion.asTerm.typeSignature.member(universe.TermName("apply"))
case sym => sym
}
val params = if (constructorSymbol.isMethod) {
constructorSymbol.asMethod.paramLists
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ object TestingUDT {
}
}

trait ScroogeLikeExample extends Product1[Int] with java.io.Serializable {
import ScroogeLikeExample._

def _1: Int

def canEqual(other: Any): Boolean = other.isInstanceOf[ScroogeLikeExample]
}

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._
Expand Down Expand Up @@ -335,4 +350,10 @@ class ScalaReflectionSuite extends SparkFunSuite {
assert(linkedHashMapDeserializer.dataType == ObjectType(classOf[LHMap[_, _]]))
}

test("SPARK-8288") {
val schema = schemaFor[ScroogeLikeExample]
assert(schema === Schema(
StructType(Seq(
StructField("x", IntegerType, nullable = false))), nullable = true))
}
}