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 @@ -47,10 +47,13 @@ object ScalaReflection {
val TypeRef(_, _, Seq(optType)) = t
Schema(schemaFor(optType).dataType, nullable = true)
case t if t <:< typeOf[Product] =>
val params = t.member("<init>": TermName).asMethod.paramss
val formalTypeArgs = t.typeSymbol.asClass.typeParams
val TypeRef(_, _, actualTypeArgs) = t
val params = t.member(nme.CONSTRUCTOR).asMethod.paramss
Schema(StructType(
params.head.map { p =>
val Schema(dataType, nullable) = schemaFor(p.typeSignature)
val Schema(dataType, nullable) =
schemaFor(p.typeSignature.substituteTypes(formalTypeArgs, actualTypeArgs))
StructField(p.name.toString, dataType, nullable)
}), nullable = true)
// Need to decide if we actually need a special type here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ case class ComplexData(
mapField: Map[Int, String],
structField: PrimitiveData)

case class GenericData[A](
genericField: A)

class ScalaReflectionSuite extends FunSuite {
import ScalaReflection._

Expand Down Expand Up @@ -128,4 +131,21 @@ class ScalaReflectionSuite extends FunSuite {
nullable = true))),
nullable = true))
}

test("generic data") {
val schema = schemaFor[GenericData[Int]]
assert(schema === Schema(
StructType(Seq(
StructField("genericField", IntegerType, nullable = false))),
nullable = true))
}

test("tuple data") {
val schema = schemaFor[(Int, String)]
assert(schema === Schema(
StructType(Seq(
StructField("_1", IntegerType, nullable = false),
StructField("_2", StringType, nullable = true))),
nullable = true))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import scala.collection.JavaConversions._
* A set of test cases that validate partition and column pruning.
*/
class PruningSuite extends HiveComparisonTest {
// MINOR HACK: You must run a query before calling reset the first time.
TestHive.hql("SHOW TABLES")

// Column/partition pruning is not implemented for `InMemoryColumnarTableScan` yet, need to reset
// the environment to ensure all referenced tables in this suites are not cached in-memory.
// Refer to https://issues.apache.org/jira/browse/SPARK-2283 for details.
Expand Down