Spark supports functions which take a "lambda like" function. Here's an example using array_sort
SELECT
  array_sort(
    ARRAY('bc', 'ab', 'dc'),
    (left, right) -> CASE
      WHEN left IS NULL
      AND right IS NULL THEN 0
      WHEN left IS NULL THEN -1
      WHEN right IS NULL THEN 1
      WHEN left < right THEN 1
      WHEN left > right THEN -1
      ELSE 0
    END
  );
 
https://spark.apache.org/docs/latest/api/sql/index.html
The issue is that sql-formatter will split the arrow -> into - >
I will fix this issue and submit a PR. Any guidance on how to best fix this is much appreciated.