2
データベースからデータを読み込むことができますが、このデータを処理します。 問題はいくつかのテーブルに 'String'という日付の列がありますが、他のものは 'timestamp'として扱います。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()
これらを一緒に形質転換する方法はありますか?または常に文字列として変換しますか?