Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maropu committed Dec 4, 2018
1 parent 0b23adb commit 7ef5f86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ object UnsafeProjection
}
}

/**
* A projection that could turn UnsafeRow into GenericInternalRow
*/
object SafeProjection extends CodeGeneratorWithInterpretedFallback[Seq[Expression], Projection] {

override protected def createCodeGeneratedObject(in: Seq[Expression]): Projection = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,19 +609,17 @@ class UnsafeRowConverterSuite extends SparkFunSuite with Matchers with PlanTestB
MapType(StringType, IntegerType),
MapType(MapType(IntegerType, StringType), MapType(StringType, ShortType)))

val mapResultRow = convertBackToInternalRow(mapRow, fields4).toSeq(fields4)
val mapExpectedRow = mapRow.toSeq(fields4)
// Since `ArrayBasedMapData` does not override `equals` and `hashCode`,
// we need to take care of it to compare rows.
// we convert it into the two `Seq`s of keys and values for correct comparisons.
def toComparable(d: Any): Any = d match {
case ar: GenericArrayData =>
ar.array.map(toComparable).toSeq
case map: ArrayBasedMapData =>
val keys = map.keyArray.array.map(toComparable).toSeq
val values = map.valueArray.array.map(toComparable).toSeq
(keys, values)
case o => o
}
val mapResultRow = convertBackToInternalRow(mapRow, fields4).toSeq(fields4)
val mapExpectedRow = mapRow.toSeq(fields4)
assert(mapResultRow.map(toComparable) === mapExpectedRow.map(toComparable))

// UDT tests
Expand Down

0 comments on commit 7ef5f86

Please sign in to comment.