Skip to content

Commit

Permalink
Move initialization of sqlparse lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Jul 26, 2023
1 parent 33d9437 commit 393cd90
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/dbt/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,12 @@ def compile_node(
the node's raw_code into compiled_code, and then calls the
recursive method to "prepend" the ctes.
"""
# Make sure Lexer for sqlparse 0.4.4 is initialized
from sqlparse.lexer import Lexer # type: ignore

if hasattr(Lexer, "get_default_instance"):
Lexer.get_default_instance()

node = self._compile_code(node, manifest, extra_context)

node, _ = self._recursively_prepend_ctes(node, manifest, extra_context)
Expand Down Expand Up @@ -563,12 +569,6 @@ def inject_ctes_into_sql(sql: str, ctes: List[InjectedCTE]) -> str:
if len(ctes) == 0:
return sql

# Make sure Lexer for sqlparse 0.4.4 is initialized
from sqlparse.lexer import Lexer # type: ignore

if hasattr(Lexer, "get_default_instance"):
Lexer.get_default_instance()

parsed_stmts = sqlparse.parse(sql)
parsed = parsed_stmts[0]

Expand Down

0 comments on commit 393cd90

Please sign in to comment.