2
我可以從數據庫加載數據,並且使用這些數據做一些處理。 問題是某些表的日期列爲'String',但其他一些則將其視爲'時間戳'。Spark,Scala - 列類型確定
我不知道什麼類型的日期列,直到加載數據。
> x.getAs[String]("date") // could be error when date column is timestamp type
> x.getAs[Timestamp]("date") // could be error when date column is string type
這是我如何從spark加載數據。
spark.read
.format("jdbc")
.option("url", url)
.option("dbtable", table)
.option("user", user)
.option("password", password)
.load()
有沒有什麼方法可以將它們特徵化?或將其轉換爲字符串總是?