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