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

Lexer default instance is set in class before keywords are added #730

Closed
gshank opened this issue Jul 27, 2023 · 1 comment
Closed

Lexer default instance is set in class before keywords are added #730

gshank opened this issue Jul 27, 2023 · 1 comment
Labels
Milestone

Comments

@gshank
Copy link

gshank commented Jul 27, 2023

In https://github.com/dbt-labs/dbt-core we use sqlparse to merge ctes at a particular place in our code. Multiple threads are started at the same time, and because the Lexer default instance is set before the keywords are added we were getting intermittent failures because we were parsing with a Lexer with no keywords.

In order to avoid this problem we had to initialize the Lexer earlier in the process: https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/compilation.py#L527

The keywords should be added to the Lexer instance before it is is stored in the class.

@andialbrecht
Copy link
Owner

Agreed. The Lexer shouldn't change iff it's a singleton and it should be thread-safe to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants