Skip to content

Commit

Permalink
[SPARK-32458][SQL][TESTS] Fix incorrectly sized row value reads
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?
Updates to tests to use correctly sized `getInt` or `getLong` calls.

### Why are the changes needed?
The reads were incorrectly sized (i.e. `putLong` paired with `getInt` and `putInt` paired with `getLong`). This causes test failures on big-endian systems.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Tests were run on a big-endian system (s390x). This change is unlikely to have any practical effect on little-endian systems.

Closes #29258 from mundaym/fix-row.

Authored-by: Michael Munday <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
  • Loading branch information
mundaym authored and dongjoon-hyun committed Jul 28, 2020
1 parent 44c868b commit a3d8056
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class RowEncoderSuite extends CodegenInterpretedPlanTest {
val encoder = RowEncoder(schema).resolveAndBind()
val localDate = java.time.LocalDate.parse("2019-02-27")
val row = toRow(encoder, Row(localDate))
assert(row.getLong(0) === DateTimeUtils.localDateToDays(localDate))
assert(row.getInt(0) === DateTimeUtils.localDateToDays(localDate))
val readback = fromRow(encoder, row)
assert(readback.get(0).equals(localDate))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ class UnsafeMapSuite extends SparkFunSuite {
val ser = new JavaSerializer(new SparkConf).newInstance()
val mapDataSer = ser.deserialize[UnsafeMapData](ser.serialize(unsafeMapData))
assert(mapDataSer.numElements() == 1)
assert(mapDataSer.keyArray().getInt(0) == 19285)
assert(mapDataSer.valueArray().getInt(0) == 19286)
assert(mapDataSer.keyArray().getLong(0) == 19285)
assert(mapDataSer.valueArray().getLong(0) == 19286)
assert(mapDataSer.getBaseObject.asInstanceOf[Array[Byte]].length == 1024)
}

test("unsafe Kryo serialization") {
val ser = new KryoSerializer(new SparkConf).newInstance()
val mapDataSer = ser.deserialize[UnsafeMapData](ser.serialize(unsafeMapData))
assert(mapDataSer.numElements() == 1)
assert(mapDataSer.keyArray().getInt(0) == 19285)
assert(mapDataSer.valueArray().getInt(0) == 19286)
assert(mapDataSer.keyArray().getLong(0) == 19285)
assert(mapDataSer.valueArray().getLong(0) == 19286)
assert(mapDataSer.getBaseObject.asInstanceOf[Array[Byte]].length == 1024)
}
}

0 comments on commit a3d8056

Please sign in to comment.