@@ -19,6 +19,7 @@ package org.apache.spark.sql.hive
1919
2020import java .sql .Date
2121import java .util
22+ import java .util .{Locale , TimeZone }
2223
2324import org .apache .hadoop .hive .serde2 .io .DoubleWritable
2425import org .apache .hadoop .hive .serde2 .objectinspector .primitive .PrimitiveObjectInspectorFactory
@@ -63,6 +64,11 @@ class HiveInspectorSuite extends FunSuite with HiveInspectors {
6364 .get())
6465 }
6566
67+ // Timezone is fixed to America/Los_Angeles for those timezone sensitive tests (timestamp_*)
68+ TimeZone .setDefault(TimeZone .getTimeZone(" America/Los_Angeles" ))
69+ // Add Locale setting
70+ Locale .setDefault(Locale .US )
71+
6672 val data =
6773 Literal (true ) ::
6874 Literal (0 .asInstanceOf [Byte ]) ::
@@ -121,11 +127,11 @@ class HiveInspectorSuite extends FunSuite with HiveInspectors {
121127
122128 def checkValues (row1 : Seq [Any ], row2 : Seq [Any ]): Unit = {
123129 row1.zip(row2).map {
124- case (r1, r2) => checkValues (r1, r2)
130+ case (r1, r2) => checkValue (r1, r2)
125131 }
126132 }
127133
128- def checkValues (v1 : Any , v2 : Any ): Unit = {
134+ def checkValue (v1 : Any , v2 : Any ): Unit = {
129135 (v1, v2) match {
130136 case (r1 : Decimal , r2 : Decimal ) =>
131137 // Ignore the Decimal precision
@@ -195,26 +201,26 @@ class HiveInspectorSuite extends FunSuite with HiveInspectors {
195201 })
196202
197203 checkValues(row, unwrap(wrap(row, toInspector(dt)), toInspector(dt)).asInstanceOf [Row ])
198- checkValues (null , unwrap(wrap(null , toInspector(dt)), toInspector(dt)))
204+ checkValue (null , unwrap(wrap(null , toInspector(dt)), toInspector(dt)))
199205 }
200206
201207 test(" wrap / unwrap Array Type" ) {
202208 val dt = ArrayType (dataTypes(0 ))
203209
204210 val d = row(0 ) :: row(0 ) :: Nil
205- checkValues (d, unwrap(wrap(d, toInspector(dt)), toInspector(dt)))
206- checkValues (null , unwrap(wrap(null , toInspector(dt)), toInspector(dt)))
207- checkValues (d, unwrap(wrap(d, toInspector(Literal (d, dt))), toInspector(Literal (d, dt))))
208- checkValues (d, unwrap(wrap(null , toInspector(Literal (d, dt))), toInspector(Literal (d, dt))))
211+ checkValue (d, unwrap(wrap(d, toInspector(dt)), toInspector(dt)))
212+ checkValue (null , unwrap(wrap(null , toInspector(dt)), toInspector(dt)))
213+ checkValue (d, unwrap(wrap(d, toInspector(Literal (d, dt))), toInspector(Literal (d, dt))))
214+ checkValue (d, unwrap(wrap(null , toInspector(Literal (d, dt))), toInspector(Literal (d, dt))))
209215 }
210216
211217 test(" wrap / unwrap Map Type" ) {
212218 val dt = MapType (dataTypes(0 ), dataTypes(1 ))
213219
214220 val d = Map (row(0 ) -> row(1 ))
215- checkValues (d, unwrap(wrap(d, toInspector(dt)), toInspector(dt)))
216- checkValues (null , unwrap(wrap(null , toInspector(dt)), toInspector(dt)))
217- checkValues (d, unwrap(wrap(d, toInspector(Literal (d, dt))), toInspector(Literal (d, dt))))
218- checkValues (d, unwrap(wrap(null , toInspector(Literal (d, dt))), toInspector(Literal (d, dt))))
221+ checkValue (d, unwrap(wrap(d, toInspector(dt)), toInspector(dt)))
222+ checkValue (null , unwrap(wrap(null , toInspector(dt)), toInspector(dt)))
223+ checkValue (d, unwrap(wrap(d, toInspector(Literal (d, dt))), toInspector(Literal (d, dt))))
224+ checkValue (d, unwrap(wrap(null , toInspector(Literal (d, dt))), toInspector(Literal (d, dt))))
219225 }
220226}
0 commit comments