sandbox: accept EXPLAIN; assistant test green (37 tests)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 changed file +2 −1
modified
services/ingest/src/findata_ingest/reader.py
+2 −1
@@ -122,8 +122,9 @@ def run_sql(sql: str, max_rows: int, timeout_s: int, views: dict[str, list[str]] | ||
| 122 | 122 | forbidden = re.compile(r"\b(attach|copy|export|import|install|load|create|insert|update|delete|drop|alter|pragma|set|call|read_csv|read_json|read_text|glob|httpfs)\b", re.IGNORECASE) |
| 123 | 123 | if forbidden.search(sql) or ";" in sql.strip().rstrip(";"): |
| 124 | 124 | raise ValueError("only a single read-only SELECT statement is allowed") |
| 125 | − if not re.match(r"^\s*(select|with|describe|show|summarize)\b", sql, re.IGNORECASE): | |
| 125 | + if not re.match(r"^\s*(select|with|describe|show|summarize|explain)\b", sql, re.IGNORECASE): | |
| 126 | 126 | raise ValueError("statement must start with SELECT / WITH") |
| 127 | + is_explain = bool(re.match(r"^\s*explain\b", sql, re.I)) | |
| 127 | 128 | con = _con() |
| 128 | 129 | lake_root = str(Lake().root).replace("'", "''") |
| 129 | 130 | con.execute(f"SET allowed_directories = ['{lake_root}/curated', '{lake_root}/_retired']") |
| 130 | 131 | |