Skip to content

Commit 7ef5f86

Browse files
committed
Fix
1 parent 0b23adb commit 7ef5f86

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ object UnsafeProjection
166166
}
167167
}
168168

169+
/**
170+
* A projection that could turn UnsafeRow into GenericInternalRow
171+
*/
169172
object SafeProjection extends CodeGeneratorWithInterpretedFallback[Seq[Expression], Projection] {
170173

171174
override protected def createCodeGeneratedObject(in: Seq[Expression]): Projection = {

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/UnsafeRowConverterSuite.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,19 +609,17 @@ class UnsafeRowConverterSuite extends SparkFunSuite with Matchers with PlanTestB
609609
MapType(StringType, IntegerType),
610610
MapType(MapType(IntegerType, StringType), MapType(StringType, ShortType)))
611611

612+
val mapResultRow = convertBackToInternalRow(mapRow, fields4).toSeq(fields4)
613+
val mapExpectedRow = mapRow.toSeq(fields4)
612614
// Since `ArrayBasedMapData` does not override `equals` and `hashCode`,
613-
// we need to take care of it to compare rows.
615+
// we convert it into the two `Seq`s of keys and values for correct comparisons.
614616
def toComparable(d: Any): Any = d match {
615-
case ar: GenericArrayData =>
616-
ar.array.map(toComparable).toSeq
617617
case map: ArrayBasedMapData =>
618618
val keys = map.keyArray.array.map(toComparable).toSeq
619619
val values = map.valueArray.array.map(toComparable).toSeq
620620
(keys, values)
621621
case o => o
622622
}
623-
val mapResultRow = convertBackToInternalRow(mapRow, fields4).toSeq(fields4)
624-
val mapExpectedRow = mapRow.toSeq(fields4)
625623
assert(mapResultRow.map(toComparable) === mapExpectedRow.map(toComparable))
626624

627625
// UDT tests

0 commit comments

Comments
 (0)