Skip to content

Commit c2de34e

Browse files
authored
fix: increase sqlparse token limit (#511)
The sqlparse library we use for statement splitting has a default limit of 10k tokens. This is not enough for some queries that contain literals. Increase the limit to 50k.
1 parent 3ac62ea commit c2de34e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/firebolt/common/statement_formatter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from sqlparse import parse as parse_sql # type: ignore
66
from sqlparse import tokens as _T
7+
from sqlparse.engine import grouping as _grouping
78
from sqlparse.engine.statement_splitter import (
89
StatementSplitter as _StatementSplitter,
910
)
@@ -97,6 +98,8 @@ def _patched_change_splitlevel(self, ttype, value): # type: ignore[no-untyped-d
9798

9899
setattr(_StatementSplitter, "_change_splitlevel", _patched_change_splitlevel)
99100

101+
# Increase sqplarse's token limit to handle queries with lots of literals
102+
_grouping.MAX_GROUPING_TOKENS = 50000
100103

101104
escape_chars_v2 = {
102105
"\0": "\\0",

0 commit comments

Comments
 (0)