Apache spark Spark Java:如何转换“格式”的数据集字符串列;yyyy-MM-ddThh:MM:ss.SSS+;0000“;要用格式标记时间戳吗?
我有一个数据集,其中有一列Apache spark Spark Java:如何转换“格式”的数据集字符串列;yyyy-MM-ddThh:MM:ss.SSS+;0000“;要用格式标记时间戳吗?,apache-spark,apache-spark-sql,timestamp,apache-spark-dataset,Apache Spark,Apache Spark Sql,Timestamp,Apache Spark Dataset,我有一个数据集,其中有一列lastModified,类型为字符串,格式为“yyyy-MM-ddThh:MM:ss.SSS+0000”(示例数据:2018-08-17T19:58:46.000+0000) 我必须通过将lastModified的值转换为格式“yyyy-MM-dd hh:MM:ss.SSS”来添加时间戳类型的新列lastModif\u-mapped 我尝试了下面的代码,但新列中的值为null: Dataset<Row> filtered = null; filtered
lastModified
,类型为字符串,格式为“yyyy-MM-ddThh:MM:ss.SSS+0000”(示例数据:2018-08-17T19:58:46.000+0000
)
我必须通过将lastModified
的值转换为格式“yyyy-MM-dd hh:MM:ss.SSS”来添加时间戳类型的新列lastModif\u-mapped
我尝试了下面的代码,但新列中的值为null
:
Dataset<Row> filtered = null;
filtered = ds1.select(ds1.col("id"),ds1.col("lastmodified"))
.withColumn("lastModif_mapped", functions.unix_timestamp(ds1.col("lastmodified"), "yyyy-MM-dd HH:mm:ss.SSS").cast("timestamp")).alias("lastModif_mapped");
Dataset filtered=null;
filtered=ds1.select(ds1.col(“id”)、ds1.col(“lastmodified”))
.withColumn(“lastModif_映射”)、functions.unix_时间戳(ds1.col(“lastmodified”)、“yyyy-MM-dd-HH:MM:ss.SSS”).cast(“时间戳”)。别名(“lastModif_映射”);
我哪里做错了