Skip to content

Commit d5c47f8

Browse files
smungeecloud-fan
authored andcommitted
[SPARK-15321] Fix bug where Array[Timestamp] cannot be encoded/decoded correctly
## What changes were proposed in this pull request? Fix `MapObjects.itemAccessorMethod` to handle `TimestampType`. Without this fix, `Array[Timestamp]` cannot be properly encoded or decoded. To reproduce this, in `ExpressionEncoderSuite`, if you add the following test case: `encodeDecodeTest(Array(Timestamp.valueOf("2016-01-29 10:00:00")), "array of timestamp") ` ... you will see that (without this fix) it fails with the following output: ``` - encode/decode for array of timestamp: [Ljava.sql.Timestamp;fd9ebde *** FAILED *** Exception thrown while decoding Converted: [0,1000000010,800000001,52a7ccdc36800] Schema: value#61615 root -- value: array (nullable = true) |-- element: timestamp (containsNull = true) Encoder: class[value[0]: array<timestamp>] (ExpressionEncoderSuite.scala:312) ``` ## How was this patch tested? Existing tests Author: Sumedh Mungee <[email protected]> Closes apache#13108 from smungee/fix-itemAccessorMethod.
1 parent 66ec249 commit d5c47f8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders/ExpressionEncoderSuite.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class ExpressionEncoderSuite extends PlanTest with AnalysisTest {
115115
encodeDecodeTest("hello", "string")
116116
encodeDecodeTest(Date.valueOf("2012-12-23"), "date")
117117
encodeDecodeTest(Timestamp.valueOf("2016-01-29 10:00:00"), "timestamp")
118+
encodeDecodeTest(Array(Timestamp.valueOf("2016-01-29 10:00:00")), "array of timestamp")
118119
encodeDecodeTest(Array[Byte](13, 21, -23), "binary")
119120

120121
encodeDecodeTest(Seq(31, -123, 4), "seq of int")

0 commit comments

Comments
 (0)