sqlfluff / sqlfluff

A modular SQL linter and auto-formatter with support for multiple dialects and templated code.

Home Page:https://www.sqlfluff.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ARRAY datatype not being parsed correctly with Trino dialect

kirkhansen opened this issue Β· comments

Search before asking

  • I searched the issues and found no similar issues.

What Happened

I had some SQL making use of the ARRAY type and got some unexpected results. Boiling it down to a simple example:

SELECT ARRAY[ARRAY[1, 2], ARRAY[3, 4]];

returns

== [../query.sql] FAIL                                                                                                                                                                                                                                                                    
L:   1 | P:  21 |  PRS | Line 1, Position 21: Found unparsable section: ', 2'
L:   1 | P:  25 |  PRS | Line 1, Position 25: Found unparsable section: ',
                       | ARRAY[3, 4]'
WARNING: Parsing errors found and dialect is set to 'trino'. Have you configured your dialect correctly?
All Finished πŸ“œ πŸŽ‰!

Expected Behaviour

SQLFluff should recognize ARRAY as a type and not error out.

Observed Behaviour

SQLFLuff errors out unable to parse a query that works with Trino.

How to reproduce

Create a one-line SQL file called query.sql with the following contents:

SELECT ARRAY[ARRAY[1, 2], ARRAY[3, 4]];

Then run the following command with the latest SQLFluff release:

sqlfluff lint --dialect=trino ../query.sql

Dialect

trino

Version

sqlfluff --version
sqlfluff, version 2.3.5
python --version
Python 3.11.8

Configuration

No configuration file was used. This can be triggered with the default configuration.

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct