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 PostgreSQL Explain lexer #2398

Merged
merged 8 commits into from Apr 4, 2023
Merged

Add PostgreSQL Explain lexer #2398

merged 8 commits into from Apr 4, 2023

Conversation

anayrat
Copy link
Contributor

@anayrat anayrat commented Mar 31, 2023

Hello,

I suggest this lexer to handle PostgreSQL execution plan obtained thanks to EXPLAIN command (https://www.postgresql.org/docs/current/sql-explain.html).

This work was inspired by Maxence Ahlouche work (https://github.com/maahl/pg_explain_lexer).

I tried to do my best to test and handle most of the cases. I added a keyword [...] which can be useful to truncate very long lines.

Thanks

This lexer add support for PostgreSQL Explain plan :

https://www.postgresql.org/docs/current/sql-explain.html

This was heavily inspired by Maxence Ahlouche work, thanks to him :
https://github.com/maahl/pg_explain_lexer
pygments/lexers/sql.py Outdated Show resolved Hide resolved
pygments/lexers/sql.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jeanas jeanas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits. Can you please add some tests too?

pygments/lexers/sql.py Outdated Show resolved Hide resolved
pygments/lexers/sql.py Outdated Show resolved Hide resolved
@anayrat
Copy link
Contributor Author

anayrat commented Apr 2, 2023

LGTM with nits. Can you please add some tests too?

Thanks for your review! I will try to add some tests, but it will be hard to cover all the rules :/

@jeanas
Copy link
Contributor

jeanas commented Apr 4, 2023

Now looks good (I added a commit to fix minor issues), only awaiting some tests. (See https://pygments.org/docs/contributing/#how-lexers-are-tested for how to add them.)

@anayrat
Copy link
Contributor Author

anayrat commented Apr 4, 2023

Thanks! I added some tests. Unfortunately, it is hard to cover all keywords :(

@jeanas
Copy link
Contributor

jeanas commented Apr 4, 2023

No need to cover all elements of a words(...) list. It's best if you can cover as many different rules of the lexer, though.

@jeanas jeanas merged commit ef0abba into pygments:master Apr 4, 2023
15 checks passed
@jeanas
Copy link
Contributor

jeanas commented Apr 4, 2023

Thanks!

@anayrat anayrat deleted the explain branch April 4, 2023 11:27
@Anteru Anteru added this to the 2.15.0 milestone Apr 10, 2023
@Anteru Anteru added the A-lexing area: changes to individual lexers label Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lexing area: changes to individual lexers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants