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

Strange formatting for Athena SQL array/map types #500

Closed
benjamin-awd opened this issue Oct 17, 2023 · 4 comments · Fixed by #503
Closed

Strange formatting for Athena SQL array/map types #500

benjamin-awd opened this issue Oct 17, 2023 · 4 comments · Fixed by #503
Labels
bug Something isn't working

Comments

@benjamin-awd
Copy link
Contributor

benjamin-awd commented Oct 17, 2023

Describe the bug
Athena has array and map datatypes, that use < and > characters. Running sqlfmt on queries that use these types produce unexpected behaviour.

Expected behavior

select cast(json_parse(foo) as array<map<varchar,varchar>>) from dwh.table

Actual behavior
Strange spacing in between < and > separators

select cast(json_parse(foo) as array<map < varchar, varchar> >) from dwh.table

Additional context
What is the output of sqlfmt --version?

sqlfmt, version 0.20.0

Note: non-breaking, but not ideal

@tconbeer
Copy link
Owner

We support similar syntax for structs amd arrays in BQ. I think we may just have to add the "map" keyword into that lever.

@tconbeer tconbeer added the bug Something isn't working label Oct 17, 2023
benjamin-awd added a commit to benjamin-awd/sqlfmt that referenced this issue Oct 17, 2023
@benjamin-awd
Copy link
Contributor Author

benjamin-awd commented Oct 17, 2023

Raised a PR #503

benjamin-awd added a commit to benjamin-awd/sqlfmt that referenced this issue Oct 17, 2023
@tconbeer tconbeer linked a pull request Oct 20, 2023 that will close this issue
tconbeer pushed a commit that referenced this issue Oct 20, 2023
@benjamin-awd
Copy link
Contributor Author

benjamin-awd commented Nov 2, 2023

So apparently sqlfluff lints map<...> statements, and actually expects something like this:
select cast(json_parse(foo) as array<map <varchar, varchar>>) from dwh.table (note the additional whitespace in front of map)

The specific sqfluff rule is:

L:  57 | P:  57 | LT01 | Expected single whitespace between 'map' keyword and                    
                       | start angle bracket '<'. [layout.spacing]

Not sure if the best solution here is to simply ignore the layout.spacing rule

@tconbeer
Copy link
Owner

tconbeer commented Nov 2, 2023

Yeah that makes no sense to have a space after map but not array. I'd ignore that rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants