Я хочу преобразовать метку времени, которая выглядит как 2019-03-25T00: 27: 46.985-0500, в этот формат2019-03-25 00:27:46
Использование Spark v2.3.0 Scala v2.11.8
время ColA ColB ColC 2019-03-25T00: 27: 46.985-0500 ABC 2019-03-25T00: 27: 46.960-0500 ABC 2019-03-25T00: 27: 46.839-0500 ABC 2019-03-25T00: 27: 46.596-0500 ABC 2019-03-25T00: 27: 46.559-0500 ABC 2019-03-25T00: 27: 46.535-0500 ABC 2019-03-25T00: 27: 46.453-0500 ABC 2019-03-25T00:27: 46.405-0500 ABC 2019-03-25T00: 27: 46.393-0500 ABC
val log = spark.read.format("csv")
.option("inferSchema", "true")
.option("header", "true")
.option("sep", ",")
.option("quote", "\"")
.option("multiLine", "true")
.load("time.csv")
scala> log.printSchema
root
|-- time: string (nullable = true)
|-- ColA: string (nullable = true)
|-- ColB: string (nullable = true)
|-- ColC: string (nullable = true)
val logs = log.withColumn("Id", monotonicallyIncreasingId()+1)
val df = spark.sql("select Id, time, ColA from logs")
Ввод: 2019-03-25T00: 27: 46.985-05: 00 Ожидаемый результат: 2019-03-2500: 27: 46