Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark Spark Java:如何转换“格式”的数据集字符串列;yyyy-MM-ddThh:MM:ss.SSS+;0000“;要用格式标记时间戳吗?_Apache Spark_Apache Spark Sql_Timestamp_Apache Spark Dataset - Fatal编程技术网

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_映射”);
我哪里做错了