Skip to content

Commit

Permalink
use re for barckets space fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad18557 committed Sep 17, 2024
1 parent 7d97f64 commit a4664a1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eval/api_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import requests
from utils.reporting import upload_results
import sqlparse
import re


def clean_generated_query(query: str):
Expand All @@ -34,9 +35,8 @@ def clean_generated_query(query: str):
query = query.replace("/ NULLIF (", "/ NULLIF (1.0 * ")

# remove extra spaces around brackets especially for MySQL
query = query.replace(" ( ", "(").replace(" )", ")")
query = query.replace(" (", "(").replace(") ", ")")
query = query.replace("( ", "(").replace(" )", ")")
query = re.sub(r"\s*\(\s*", "(", query) # Remove spaces before and after '('
query = re.sub(r"\s*\)", ")", query) # Remove spaces before ')'

return query

Expand Down

0 comments on commit a4664a1

Please sign in to comment.