Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrow symbole in Spark queries using lambda like functions ex: array_sort #176

Closed
cccs-jc opened this issue Sep 27, 2021 · 2 comments
Closed
Labels
Milestone

Comments

@cccs-jc
Copy link

cccs-jc commented Sep 27, 2021

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.

@inferrinizzard
Copy link
Collaborator

Hi, this issue is fixed in my fork here:
https://github.com/inferrinizzard/prettier-sql
https://www.npmjs.com/package/prettier-sql

@nene
Copy link
Collaborator

nene commented May 3, 2022

Fixed also in master branch.

@nene nene closed this as completed May 3, 2022
@nene nene added the bug label May 3, 2022
@nene nene added this to the Version 6 milestone May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants