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

Add parsing support for Postgres "EXPLAIN" statement #893

Closed
roblevy opened this issue Mar 25, 2021 · 3 comments · Fixed by #951
Closed

Add parsing support for Postgres "EXPLAIN" statement #893

roblevy opened this issue Mar 25, 2021 · 3 comments · Fixed by #951
Assignees
Labels
dialect Issue related to general dialect support. Use dialect-specific label instead where appropriate enhancement New feature or request postgres Issues relating to the Postgres dialect

Comments

@roblevy
Copy link

roblevy commented Mar 25, 2021

The first example from the Postgres EXPLAIN docs is:

EXPLAIN SELECT * FROM foo;

Expected Behaviour

>>> sqlfluff.parse("EXPLAIN SELECT * FROM foo;", dialect="postgres")
ParsedString(...)

Observed Behaviour

SQLParseError: Found unparsable section: 'EXPLAIN SELECT * FROM foo'

Steps to Reproduce

import sqlfluff
sqlfluff.parse("EXPLAIN SELECT * FROM foo;", dialect="postgres")

Version

sqlfluff: 0.4.1
Python: 3.8.6

Configuration

No configuration file.

@roblevy roblevy added the bug Something isn't working label Mar 25, 2021
@alanmcruickshank
Copy link
Member

@roblevy , thanks for the Issue report! We might have to implement this seperately for different dialects, each one seems to have a slightly different syntax. So that we cover your use case, which dialects are you most likely to use?

Docs for reference:

@roblevy
Copy link
Author

roblevy commented Mar 27, 2021 via email

@barrywhart barrywhart added enhancement New feature or request and removed bug Something isn't working labels Apr 6, 2021
@barrywhart barrywhart changed the title EXPLAIN is unparsable Add parsing support for Postgres "EXPLAIN" statement Apr 6, 2021
@barrywhart barrywhart added dialect Issue related to general dialect support. Use dialect-specific label instead where appropriate postgres Issues relating to the Postgres dialect labels Apr 6, 2021
@dmateusp dmateusp self-assigned this Apr 11, 2021
@dmateusp
Copy link
Contributor

@alanmcruickshank I ended up implementing the MySQL flavor as ANSI (it's the simplest case), and separately implemented a Snowflake and Postgres version, with Postgres being the most complicated (I actually had to spin up a Postgres on Docker to wrap my head around what's valid there)

#951

dmateusp pushed a commit to dmateusp/sqlfluff that referenced this issue Apr 12, 2021
dmateusp pushed a commit that referenced this issue Apr 12, 2021
* Add ANSI + MySQL 'explain'

* Add Snowflake explain 🥶

* Add the _more complicated_ postgres explain 🧪

* Update CHANGELOG ✏️

* Mypy 🧹
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialect Issue related to general dialect support. Use dialect-specific label instead where appropriate enhancement New feature or request postgres Issues relating to the Postgres dialect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants