@@ -27,11 +27,7 @@ import scala.reflect.runtime.universe.TypeTag
2727import com .google .common .collect .MapMaker
2828
2929import org .apache .spark .rdd .RDD
30- import org .apache .spark .sql .catalyst .{CatalystTypeConverters , ScalaReflection }
31- import org .apache .spark .sql .catalyst .encoders ._
32- import org .apache .spark .sql .catalyst .encoders .ExpressionEncoder
33- import org .apache .spark .sql .catalyst .expressions .UnsafeRow
34- import org .apache .spark .sql .catalyst .plans .logical .LocalRelation
30+ import org .apache .spark .sql .catalyst .CatalystTypeConverters
3531import org .apache .spark .sql .execution .datasources .parquet .ParquetTest
3632import org .apache .spark .sql .functions ._
3733import org .apache .spark .sql .test .SharedSQLContext
@@ -101,27 +97,6 @@ class UserDefinedTypeSuite extends QueryTest with SharedSQLContext with ParquetT
10197 private val outers : ConcurrentMap [String , AnyRef ] = new MapMaker ().weakValues().makeMap()
10298 outers.put(getClass.getName, this )
10399
104- test(" user type with ScalaReflection" ) {
105- val points = Seq (
106- MyLabeledPoint (1.0 , new MyDenseVector (Array (0.1 , 1.0 ))),
107- MyLabeledPoint (0.0 , new MyDenseVector (Array (0.2 , 2.0 ))))
108-
109- val schema = ScalaReflection .schemaFor[MyLabeledPoint ].dataType.asInstanceOf [StructType ]
110- val attributeSeq = schema.toAttributes
111-
112- val pointEncoder = encoderFor[MyLabeledPoint ]
113- val unsafeRows = points.map(pointEncoder.toRow(_).copy())
114- val df = DataFrame (sqlContext, LocalRelation (attributeSeq, unsafeRows))
115- val decodedPoints = df.collect()
116- points.zip(decodedPoints).foreach { case (p, p2) =>
117- assert(p.label == p2(0 ) && p.features == p2(1 ))
118- }
119-
120- val boundEncoder = pointEncoder.resolve(attributeSeq, outers).bind(attributeSeq)
121- val point = MyLabeledPoint (1.0 , new MyDenseVector (Array (0.1 , 1.0 )))
122- assert(boundEncoder.fromRow(boundEncoder.toRow(point)) === point)
123- }
124-
125100 test(" UDTs and UDFs" ) {
126101 sqlContext.udf.register(" testType" , (d : MyDenseVector ) => d.isInstanceOf [MyDenseVector ])
127102 pointsRDD.registerTempTable(" points" )
0 commit comments