Skip to content

Commit 9c0e4e1

Browse files
committed
Remove last use of convertToScala().
1 parent ae3278d commit 9c0e4e1

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/CatalystTypeConverters.scala

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff 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

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/generators.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff 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(",")})"

0 commit comments

Comments
 (0)