title: How to limit functions.collect_set in Spark SQL?
body: <p>I'm dealing with a column of numbers in a large spark DataFrame, and I would like to create a new column that stores an aggregated list of unique numbers that appear in that column. </p>
  
  <p>Basically exactly what functions.collect_set does. However, i only need up to 1000 elements in the aggregated list. Is there any way to pass that parameter somehow to functions.collect_set(), or any other way to get only up to 1000 elements in the aggregated list, without using a UDAF?</p>
  
  <p>Since the column is so large, I'd like to avoid collecting all elements and trimming the list afterwards.</p>
  
  <p>Thanks!</p>