Apache spark 获取Spark SQL date_格式和weekofyear之间的日期周不同
一个非常简单的例子:Apache spark 获取Spark SQL date_格式和weekofyear之间的日期周不同,apache-spark,apache-spark-sql,Apache Spark,Apache Spark Sql,一个非常简单的例子: SELECT date_format("2018-01-14", "w"), weekofyear("2018-01-14") 给出: 3, 2 它们都应该返回2,如何正确配置区域设置 (环境user.country=fruser.lang=fr) 我可以看到这一周从周一开始。从2.2.1版开始(但也在当前的master分支上),在中定义了date\u格式,这反过来又使用了,不幸的是,它使用了硬编码的Locale.US,您无法配置其行为 def newDateForm
SELECT date_format("2018-01-14", "w"), weekofyear("2018-01-14")
给出:
3, 2
它们都应该返回2,如何正确配置区域设置
(环境user.country
=fruser.lang
=fr)
我可以看到这一周从周一开始。从2.2.1版开始(但也在当前的master
分支上),在中定义了date\u格式,这反过来又使用了,不幸的是,它使用了硬编码的Locale.US
,您无法配置其行为
def newDateFormat(formatString: String, timeZone: TimeZone): DateFormat = {
val sdf = new SimpleDateFormat(formatString, Locale.US)
sdf.setTimeZone(timeZone)
// Enable strict parsing, if the input date/format is invalid, it will throw an exception.
// e.g. to parse invalid date '2016-13-12', or '2016-01-12' with invalid format 'yyyy-aa-dd',
// an exception will be throwed.
sdf.setLenient(false)
sdf
}
看来这两个人肯定有不同的行为。也许你会想要并且可能会为此申请一张罚单