File tree Expand file tree Collapse file tree 2 files changed +7
-12
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -353,15 +353,6 @@ object CatalystTypeConverters {
353353 case other => other
354354 }
355355
356- /**
357- * Converts Catalyst types used internally in rows to standard Scala types
358- * This method is slow, and for batch conversion you should be using converter
359- * produced by createToScalaConverter.
360- */
361- def convertToScala (catalystValue : Any , dataType : DataType ): Any = {
362- getConverterForType(dataType).toScala(catalystValue)
363- }
364-
365356 /**
366357 * Creates a converter function that will convert Catalyst types to Scala type.
367358 * Typical use case would be converting a collection of rows that have the same schema. You will
Original file line number Diff line number Diff line change @@ -71,12 +71,16 @@ case class UserDefinedGenerator(
7171 children : Seq [Expression ])
7272 extends Generator {
7373
74+ private [this ] val inputRow : InterpretedProjection = new InterpretedProjection (children)
75+ private [this ] val convertToScala : (Row ) => Row = {
76+ val inputSchema = StructType (children.map(e => StructField (e.simpleString, e.dataType, true )))
77+ CatalystTypeConverters .createToScalaConverter(inputSchema)
78+ }.asInstanceOf [(Row => Row )]
79+
7480 override def eval (input : Row ): TraversableOnce [Row ] = {
7581 // TODO(davies): improve this
7682 // Convert the objects into Scala Type before calling function, we need schema to support UDT
77- val inputSchema = StructType (children.map(e => StructField (e.simpleString, e.dataType, true )))
78- val inputRow = new InterpretedProjection (children)
79- function(CatalystTypeConverters .convertToScala(inputRow(input), inputSchema).asInstanceOf [Row ])
83+ function(convertToScala(inputRow(input)))
8084 }
8185
8286 override def toString : String = s " UserDefinedGenerator( ${children.mkString(" ," )}) "
You can’t perform that action at this time.
0 commit comments