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

[FORMATTING] Can't handle trino between date clause #507

Closed
rigogsilva opened this issue Oct 24, 2022 · 2 comments
Closed

[FORMATTING] Can't handle trino between date clause #507

rigogsilva opened this issue Oct 24, 2022 · 2 comments
Labels

Comments

@rigogsilva
Copy link

Input data

Which SQL and options did you provide as input?

    format(query, {
      language: "trino",
      tabWidth: 2,
      logicalOperatorNewline: "before"
    })
SELECT * from test
  AND date_field BETWEEN DATE '2022-06-01' AND DATE '2022-08-09'

Expected Output

Any formatting.

Usage

  • How are you calling / using the library?
    format(query, {
      language: "trino",
      tabWidth: 2,
      logicalOperatorNewline: "before"
    })
  • What SQL language(s) does this apply to?
    trino

  • Which SQL Formatter version are you using?
    "sql-formatter": "^11.0.2"

error:

Command 'trinols: Format' resulted in an error (Parse error at token: '2022-06-01' at line 2 column 31
Unexpected STRING token: {"type":"STRING","raw":"'2022-06-01'","text":"'2022-06-01'","start":49,"precedingWhitespace":" "}. Instead, I was expecting to see one of the following:

A AND token based on:
between_predicate → %BETWEEN _ expression _ ● %AND _ expression
asteriskless_free_form_sql$subexpression$1 →  ● 
@rigogsilva rigogsilva added the bug label Oct 24, 2022
@nene
Copy link
Collaborator

nene commented Oct 24, 2022

Thanks for reporting.

Unfortunately the date/time literal syntax is not correctly handled, plus the parsing of BETWEEN operator is somewhat crappy. I guess this syntax would have worked in some earlier version before the BETWEEN-expression parsing was rewritten, but then again these earlier versions don't have Trino support.

Unfortunately no quick fix for that. I'm working on a longer-term solution, but that will take some time.

@nene
Copy link
Collaborator

nene commented Nov 17, 2022

This should now be fixed in 12.0.2 release.

@nene nene closed this as completed Nov 17, 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

2 participants