I am really new to PySpark. All I want to do is to find the maximum of the "date" column and add a new column in the dataframe that has this maximum date for all the rows (repeating) such that:
A B C
a timestamp1 timestamp3
b timestamp2 --------------------> timestamp3
c timestamp3 timestamp3
I use the following line of code:
df.withColumn('dummy_column',f.lit((f.max('date'))).cast('timestamp')).show(9)
But I get the error:
> AnalysisException: grouping expressions sequence is empty, and
> '`part`' is not an aggregate function. Wrap '(CAST(max(`date`) AS
> TIMESTAMP) AS `new_column`)' in windowing function(s) or wrap '`part`'
> in first() (or first_value) if you don't care which value you get.;;
Can anyone help me understand why do I get this error and how can I work around it?