Skip to content

Commit 0ae16f1

Browse files
authored
Merge pull request #6 from wtysos11/fix_timediff
Fix timediff.py
2 parents dc61811 + 8fc2150 commit 0ae16f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

timediff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import pyspark
99
from pyspark.sql import SparkSession
10-
from pyspark.sql.functions import col
10+
from pyspark.sql.functions import col, round
1111
from pyspark.sql.functions import to_timestamp, current_timestamp
1212
from pyspark.sql.types import StructType, StructField, StringType, IntegerType, LongType
1313

@@ -25,7 +25,7 @@
2525

2626
df.withColumn('input_timestamp',to_timestamp(col('input_timestamp')))\
2727
.withColumn('current_timestamp', current_timestamp().alias('current_timestamp'))\
28-
.withColumn('DiffInSeconds',current_timestamp().cast(LongType) - col('input_timestamp').cast(LongType))\
28+
.withColumn('DiffInSeconds',current_timestamp().cast(LongType()) - col('input_timestamp').cast(LongType()))\
2929
.withColumn('DiffInMinutes',round(col('DiffInSeconds')/60))\
3030
.withColumn('DiffInHours',round(col('DiffInSeconds')/3600))\
3131
.withColumn('DiffInDays',round(col('DiffInSeconds')/24*3600))\

0 commit comments

Comments
 (0)