|
3 | 3 | import logging |
4 | 4 | import re |
5 | 5 | from types import TracebackType |
6 | | -from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union |
| 6 | +from typing import Any, Dict, List, Optional, Tuple, Type, Union |
7 | 7 |
|
8 | 8 | from httpx import URL, Response |
9 | 9 |
|
10 | 10 | from firebolt.client.auth.base import Auth |
11 | 11 | from firebolt.client.client import AsyncClient, Client |
12 | | -from firebolt.common._types import ParameterType, RawColType, SetParameter |
| 12 | +from firebolt.common._types import RawColType, SetParameter |
13 | 13 | from firebolt.common.constants import ( |
14 | 14 | DISALLOWED_PARAMETER_LIST, |
15 | 15 | IMMUTABLE_PARAMETER_LIST, |
|
27 | 27 | SecureCacheKey, |
28 | 28 | _firebolt_cache, |
29 | 29 | ) |
30 | | -from firebolt.utils.exception import ( |
31 | | - ConfigurationError, |
32 | | - FireboltError, |
33 | | - ProgrammingError, |
34 | | -) |
| 30 | +from firebolt.utils.exception import ConfigurationError, FireboltError |
35 | 31 | from firebolt.utils.util import fix_url_schema |
36 | 32 |
|
37 | 33 | logger = logging.getLogger(__name__) |
@@ -240,6 +236,7 @@ def _log_query(query: Union[str, SetParameter]) -> None: |
240 | 236 | "aws_key_id|credentials", query, flags=re.IGNORECASE |
241 | 237 | ): |
242 | 238 | logger.debug(f"Running query: {query}") |
| 239 | + |
243 | 240 | @property |
244 | 241 | def engine_name(self) -> str: |
245 | 242 | """ |
@@ -320,44 +317,3 @@ def set_cache_record(self, record: ConnectionInfo) -> None: |
320 | 317 | self._client.auth.secret, |
321 | 318 | ) |
322 | 319 | _firebolt_cache.set(cache_key, record) |
323 | | - |
324 | | - def _validate_bulk_insert_query(self, query: str) -> None: |
325 | | - """Validate that query is an INSERT statement for bulk_insert.""" |
326 | | - query_normalized = query.lstrip().lower() |
327 | | - |
328 | | - if not query_normalized.startswith("insert"): |
329 | | - raise ConfigurationError( |
330 | | - "bulk_insert is only supported for INSERT statements" |
331 | | - ) |
332 | | - |
333 | | - if ";" in query.strip().rstrip(";"): |
334 | | - raise ProgrammingError( |
335 | | - "bulk_insert does not support multi-statement queries" |
336 | | - ) |
337 | | - |
338 | | - def _prepare_bulk_insert( |
339 | | - self, query: str, parameters_seq: Sequence[Sequence[ParameterType]] |
340 | | - ) -> tuple[str, Sequence[Sequence[ParameterType]]]: |
341 | | - """Execute multiple INSERT queries as a single batch.""" |
342 | | - self._validate_bulk_insert_query(query) |
343 | | - |
344 | | - if not parameters_seq: |
345 | | - raise ProgrammingError("bulk_insert requires at least one parameter set") |
346 | | - |
347 | | - # For bulk insert, we need to create unique parameter names for each INSERT |
348 | | - # Example: ($1, $2); ($3, $4); ($5, $6) instead of ($1, $2); ($1, $2); ($1, $2) |
349 | | - queries = [] |
350 | | - param_offset = 0 |
351 | | - for param_set in parameters_seq: |
352 | | - # Replace parameter placeholders with unique numbers |
353 | | - modified_query = query |
354 | | - for i in range(len(param_set)): |
355 | | - old_param = f"${i + 1}" |
356 | | - new_param = f"${param_offset + i + 1}" |
357 | | - modified_query = modified_query.replace(old_param, new_param) |
358 | | - queries.append(modified_query) |
359 | | - param_offset += len(param_set) |
360 | | - |
361 | | - combined_query = "; ".join(queries) |
362 | | - parameters = [param for param_set in parameters_seq for param in param_set] |
363 | | - return combined_query, [parameters] |
0 commit comments