Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.

[FORMATTING] Space is inserted before bracket for Map keys with . and - #85

Open
drrcool opened this issue Apr 22, 2022 · 0 comments
Open
Assignees
Labels
formatting Bugs or Issues related to SQL Formatting

Comments

@drrcool
Copy link

drrcool commented Apr 22, 2022

Describe the bug
When formatting code with MAP keys that have . in them, the formatter adds a space between map name and index.

Expected Output

SELECT
    id,
    measures_map['bucket.lower'] AS bucket_lower,
    SUM(1) as cnt
FROM some.table
GROUP BY
    id,
    measures_map['bucket.lower']

Actual Output

SELECT
    id,
    measures_map ['bucket.lower'] AS bucket_lower,
    SUM(1) as cnt
FROM some.table
GROUP BY
   id,
   measures_map ['bucket_lower']

Note: if I cared about measures_map['somekey'] the formatter behaves perfectly as expected. I have not done an exhaustive search, but I see that _ are treated correctly, but . and - are not.

Usage

  • How are you calling / using the script? (Please provide a code snippet, if applicable)
    I've tried through using Format Document and Format on Save

  • What SQL language(s) does this apply to?
    I'm writing in Presto/Trino and have tried sql, bigquery, spark, and hive and get the same results

  • What Node version? (If applicable)
    v17.9.0

@drrcool drrcool added the formatting Bugs or Issues related to SQL Formatting label Apr 22, 2022
@inferrinizzard inferrinizzard self-assigned this Apr 25, 2022
@inferrinizzard inferrinizzard changed the title [FORMATTING] Issue Title Here [FORMATTING] Space is inserted before bracket for Map keys with . and - Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
formatting Bugs or Issues related to SQL Formatting
Projects
None yet
Development

No branches or pull requests

2 participants