Skip to content

Commit 54d44fa

Browse files
committed
fix(spanner/dbapi): bypass sqlparse for RUN PARTITION commands
1 parent ea185ba commit 54d44fa

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

google/cloud/spanner_dbapi/parse_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ def classify_statement(query, args=None):
233233
:rtype: ParsedStatement
234234
:returns: parsed statement attributes.
235235
"""
236+
# Check for RUN PARTITION command to avoid sqlparse processing it.
237+
# sqlparse fails with "Maximum grouping depth exceeded" on long partition IDs.
238+
if re.match(r"^\s*RUN\s+PARTITION\b", query, re.IGNORECASE | re.DOTALL):
239+
return client_side_statement_parser.parse_stmt(query.strip())
240+
236241
# sqlparse will strip Cloud Spanner comments,
237242
# still, special commenting styles, like
238243
# PostgreSQL dollar quoted comments are not

0 commit comments

Comments
 (0)