- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个来自源的日期字符串,格式为“Fri May 24 00:00:00 BST 2019”,我将使用类似我的示例的代码将其转换为日期并存储为“2019-05-24”对我来说在 spark 2.0 下
from pyspark.sql.functions import to_date, unix_timestamp, from_unixtime
df = spark.createDataFrame([("Fri May 24 00:00:00 BST 2019",)], ['date_str'])
df2 = df.select('date_str', to_date(from_unixtime(unix_timestamp('date_str', 'EEE MMM dd HH:mm:ss zzz yyyy'))).alias('date'))
df2.show(1, False)
在我的沙箱环境中,我已更新为 spark 3.0,现在上面的代码出现以下错误,是否有在 3.0 中执行此操作的新方法将我的字符串转换为日期
: org.apache.spark.SparkUpgradeException: You may get a differentresult due to the upgrading of Spark 3.0: Fail to recognize 'EEE MMMdd HH:mm:ss zzz yyyy' pattern in the DateTimeFormatter.
- You can set spark.sql.legacy.timeParserPolicy to LEGACY to restore thebehavior before Spark 3.0.
- You can form a valid datetime pattern with the guide fromhttps://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html
最佳答案
如果要在较新版本的 spark(>3) 中使用旧格式,则需要设置 spark.conf.set("spark.sql.legacy.timeParserPolicy","LEGACY")
或者spark.sql("set spark.sql.legacy.timeParserPolicy=LEGACY")
,这将解决问题。
关于apache-spark - 从 Spark 2.0 到 3.0 的字符串到日期迁移导致无法识别 DateTimeFormatter 中的 'EEE MMM dd HH:mm:ss zzz yyyy' 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62602720/
我正在尝试按照教程在 Linux 中创建自定义 USB 驱动程序,我希望使用 g++ 在我的 Eee PC 上使用 Ubuntu Eee 开发这个东西。不幸的是,为了遵循本教程,我需要 linux/m
我似乎不明白为什么它不点击这里。代码没有任何语法错误,但显然逻辑有问题。因此,基本上,第一行是白色,第二行将是其他颜色或#eee。如果有人能看到这个错误并让我知道,我将非常感激。 提前致谢! wind
为什么下面的代码会输出:Dday: (null) NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateForma
我开始开发一个 AR 应用程序,我的开发设备就是这个主题中的那个。此目标运行 Android 3.1。 我涵盖了设置我的环境所需的所有步骤,并尝试运行 QCAR SDK 提供的图像目标示例,但没有成功
我有一个应用程序正在尝试在我的 ASUS eee TF101 (未 root) 上进行调试,但它无法正常工作。每当我在 Esclipse 中单击“调试”时,我的 ASUS 都会显示“应用程序 ....
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 9 年前。 Improv
这个问题已经有答案了: java.text.ParseException: Unparseable date (10 个回答) 已关闭 6 年前。 我的日期字符串是:“Wed Oct 19 14:34
亲爱的,帮助将字符串转换为“Mon, 10 Apr 2017, 10:00:00 PDT” to Date我的代码如下,不幸的是它会导致错误: extension String { fu
这个问题在这里已经有了答案: How to convert date in to yyyy-MM-dd Format? (6 个答案) How can I convert Date.toString
我从数据库中获取日期为 2013-05-03 00:20:29.0。我想将日期解析为 EEE MMM dd HH:mm:ss zzz yyyy 格式,但是当我解析它时,出现了这个异常: java.te
我正在尝试将 EEE MMM dd HH:mm:ss ZZZ yyyy 转换为 YYYY-MM-DD 格式,以便我可以将其插入 MySQL 数据库。我没有收到任何错误,但插入到我的数据库中的日期是错误
我有一个使用“new date()”显示的日期/时间。 当前显示 "Thu May 31 2012 13:04:29 GMT-0500 (CDT)". 我需要这个: "Thu May 31 13:0
使用以下代码时出现异常: var expDate : NSDate = NSDate() let dateFormatter = NSDateFormatter() dateFormatter.dat
我想使用 JAVA 将 Thu Feb 02 00:00:00 WET 2012 转换为 02/02/2012 (日期类型不是字符串)。 我做到了 String date = "Thu Feb 02
我想将时间戳 Wed, 20 Feb 2013 11:41:23 GMT 转换为 2013-02-20T11:41:23Z 。我怎样才能做到这一点?我想要 UTC 格式的 ISO-8601(2013-
我的日期类型为“EEE MM DD HH:mm:ss zzz yyyy”(Wed Mar 04 03:34:45 GMT+08:00 2020)和“yyyy-MM-dd hh:mm:ss”( 2020
我有一个来自源的日期字符串,格式为“Fri May 24 00:00:00 BST 2019”,我将使用类似我的示例的代码将其转换为日期并存储为“2019-05-24”对我来说在 spark 2.0
我是一名优秀的程序员,十分优秀!