Skip to content

Add PostgreSQL Explain lexer - #2398

Merged
jeanas merged 8 commits into
pygments:masterfrom
anayrat:explain
Apr 4, 2023
Merged

jeanas merged 8 commits into
pygments:masterfrom
anayrat:explain

Conversation

@anayrat

@anayrat anayrat commented Mar 31, 2023

Copy link
Copy Markdown
Contributor

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

anayrat added 2 commits March 31, 2023 12:10
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
Comment thread pygments/lexers/sql.py Outdated
Comment thread pygments/lexers/sql.py Outdated

@jeanas jeanas left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread pygments/lexers/sql.py Outdated
Comment thread pygments/lexers/sql.py Outdated
@anayrat

anayrat commented Apr 2, 2023

Copy link
Copy Markdown
Contributor Author

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

jeanas commented Apr 4, 2023

Copy link
Copy Markdown
Contributor

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

anayrat commented Apr 4, 2023

Copy link
Copy Markdown
Contributor Author

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

@jeanas

jeanas commented Apr 4, 2023

Copy link
Copy Markdown
Contributor

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
@jeanas

jeanas commented Apr 4, 2023

Copy link
Copy Markdown
Contributor

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.

3 participants