Skip to content
Snippets Groups Projects
Commit 65253502 authored by luogankun's avatar luogankun Committed by Michael Armbrust
Browse files

[SPARK-3065][SQL] Add locale setting to fix results do not match for...

[SPARK-3065][SQL] Add locale setting to fix results do not match for udf_unix_timestamp format "yyyy MMM dd h:mm:ss a" run with not "America/Los_Angeles" TimeZone in HiveCompatibilitySuite

When run the udf_unix_timestamp of org.apache.spark.sql.hive.execution.HiveCompatibilitySuite testcase
with not "America/Los_Angeles" TimeZone throws error. [https://issues.apache.org/jira/browse/SPARK-3065]
add locale setting on beforeAll and afterAll method to fix the bug of HiveCompatibilitySuite testcase

Author: luogankun <luogankun@gmail.com>

Closes #1968 from luogankun/SPARK-3065 and squashes the following commits:

c167832 [luogankun] [SPARK-3065][SQL] Add Locale setting to HiveCompatibilitySuite
0a25e3a [luogankun] [SPARK-3065][SQL] Add Locale setting to HiveCompatibilitySuite
parent cc275f4b
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@
package org.apache.spark.sql.hive.execution
import java.io.File
import java.util.TimeZone
import java.util.{Locale, TimeZone}
import org.scalatest.BeforeAndAfter
......@@ -33,6 +33,7 @@ class HiveCompatibilitySuite extends HiveQueryFileTest with BeforeAndAfter {
File.separator + "test" + File.separator + "queries" + File.separator + "clientpositive")
var originalTimeZone: TimeZone = _
var originalLocale: Locale = _
def testCases = hiveQueryDir.listFiles.map(f => f.getName.stripSuffix(".q") -> f)
......@@ -41,11 +42,16 @@ class HiveCompatibilitySuite extends HiveQueryFileTest with BeforeAndAfter {
// Timezone is fixed to America/Los_Angeles for those timezone sensitive tests (timestamp_*)
originalTimeZone = TimeZone.getDefault
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"))
// Add Locale setting
originalLocale = Locale.getDefault
Locale.setDefault(Locale.US)
}
override def afterAll() {
TestHive.cacheTables = false
TimeZone.setDefault(originalTimeZone)
Locale.setDefault(originalLocale)
}
/** A list of tests deemed out of scope currently and thus completely disregarded. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment