Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove last use of convertToScala().
  • Loading branch information
JoshRosen committed May 29, 2015
commit 9c0e4e18bf3a05ac925429d46339a871a24659ac
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,6 @@ object CatalystTypeConverters {
case other => other
}

/**
* Converts Catalyst types used internally in rows to standard Scala types
* This method is slow, and for batch conversion you should be using converter
* produced by createToScalaConverter.
*/
def convertToScala(catalystValue: Any, dataType: DataType): Any = {
getConverterForType(dataType).toScala(catalystValue)
}

/**
* Creates a converter function that will convert Catalyst types to Scala type.
* Typical use case would be converting a collection of rows that have the same schema. You will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ case class UserDefinedGenerator(
children: Seq[Expression])
extends Generator {

private[this] val inputRow: InterpretedProjection = new InterpretedProjection(children)
private[this] val convertToScala: (Row) => Row = {
val inputSchema = StructType(children.map(e => StructField(e.simpleString, e.dataType, true)))
CatalystTypeConverters.createToScalaConverter(inputSchema)
}.asInstanceOf[(Row => Row)]

override def eval(input: Row): TraversableOnce[Row] = {
// TODO(davies): improve this
// Convert the objects into Scala Type before calling function, we need schema to support UDT
val inputSchema = StructType(children.map(e => StructField(e.simpleString, e.dataType, true)))
val inputRow = new InterpretedProjection(children)
function(CatalystTypeConverters.convertToScala(inputRow(input), inputSchema).asInstanceOf[Row])
function(convertToScala(inputRow(input)))
}

override def toString: String = s"UserDefinedGenerator(${children.mkString(",")})"
Expand Down