まず、私の質問を読んで時間をありがとうございました:)データフレームScalaでは別の日付でsubstract現在の日付のすべての
私の質問は以下の通りです:スカラ座でのスパークでは、私はAが含まれているデータフレームを持っています形式DD/MM/YYYYのHHの日付の文字列:ミリメートル、例えば
+----------------+
|date |
+----------------+
|8/11/2017 15:00 |
|9/11/2017 10:00 |
+----------------+
dfを私は2番目にデータフレームの日付とCURRENTDATEの違いを取得したい、例えば
df.withColumn( "difference"、currentDate - unix_timestamp(col(date)))
+----------------+------------+
|date | difference |
+----------------+------------+
|8/11/2017 15:00 | xxxxxxxxxx |
|9/11/2017 10:00 | xxxxxxxxxx |
+----------------+------------+
私は
val current = current_timestamp()
df.withColumn("difference", current - unix_timestamp(col(date)))
を試してみたが
org.apache.spark.sql.AnalysisExceptionこのエラーを取得:「(CURRENT_TIMESTAMP()を解決することはできません - UNIX_TIMESTAMP(
date
を、 (yyyy-MM-dd HH:mm:ss '))')のデータ型の不一致による違いがあります: '(current_timestamp() - unix_timestamp(date
、' yyyy-MM-タイムスタンプとbigint)。;;
は、私があまりにも
val current = BigInt(System.currenttimeMillis/1000)
df.withColumn("difference", current - unix_timestamp(col(date)))
と
val current = unix_timestamp(current_timestamp())
but the col "difference" is null
感謝してみてください
作品!どうもありがとうございました :) –