unsupportedOperationException Error converting string to DateTime using Joda time

后端 未结 3 1216
有刺的猬
有刺的猬 2021-01-21 19:16

I am converting string to datetime field using joda.time.Datetime libraries but it throws unsupported exception Here is main class code:

//create new var with          


        
3条回答
  •  时光说笑
    2021-01-21 19:59

    1. As you can read in the official documentation dates in Spark SQL are represented using java.sql.Timestamp. If you want to use Joda time you have to convert output to the correct type

    2. SparkSQL can easily handle standard date formats using type casting:

      sc.parallelize(Seq(Tuple1("2016-01-11 00:01:02")))
        .toDF("dt")
        .select($"dt".cast("timestamp"))
      

提交回复
热议问题