kazanzhy commented on code in PR #25299:
URL: https://github.com/apache/airflow/pull/25299#discussion_r930322863
##########
airflow/providers/presto/hooks/presto.py:
##########
@@ -142,82 +141,23 @@ def get_isolation_level(self) -> Any:
isolation_level = db.extra_dejson.get('isolation_level',
'AUTOCOMMIT').upper()
return getattr(IsolationLevel, isolation_level,
IsolationLevel.AUTOCOMMIT)
- @overload
- def get_records(self, sql: str = "", parameters: Optional[dict] = None):
- """Get a set of records from Presto
-
- :param sql: SQL statement to be executed.
- :param parameters: The parameters to render the SQL query with.
- """
-
- @overload
- def get_records(self, sql: str = "", parameters: Optional[dict] = None,
hql: str = ""):
- """:sphinx-autoapi-skip:"""
-
- def get_records(self, sql: str = "", parameters: Optional[dict] = None,
hql: str = ""):
- """:sphinx-autoapi-skip:"""
- if hql:
- warnings.warn(
- "The hql parameter has been deprecated. You should pass the
sql parameter.",
- DeprecationWarning,
- stacklevel=2,
- )
- sql = hql
-
+ def get_records(self, sql: Union[str, List[str]] = "", parameters:
Optional[Any] = None, **kwargs: dict):
+ if not isinstance(sql, str):
+ raise ValueError(f"The sql in Presto Hook must be a string and is
{sql}!")
try:
return super().get_records(self.strip_sql_string(sql), parameters)
except DatabaseError as e:
raise PrestoException(e)
- @overload
- def get_first(self, sql: str = "", parameters: Optional[dict] = None) ->
Any:
- """Returns only the first row, regardless of how many rows the query
returns.
-
- :param sql: SQL statement to be executed.
- :param parameters: The parameters to render the SQL query with.
- """
-
- @overload
- def get_first(self, sql: str = "", parameters: Optional[dict] = None, hql:
str = "") -> Any:
- """:sphinx-autoapi-skip:"""
-
- def get_first(self, sql: str = "", parameters: Optional[dict] = None, hql:
str = "") -> Any:
- """:sphinx-autoapi-skip:"""
- if hql:
- warnings.warn(
- "The hql parameter has been deprecated. You should pass the
sql parameter.",
- DeprecationWarning,
- stacklevel=2,
- )
- sql = hql
-
+ def get_first(self, sql: Union[str, List[str]] = "", parameters:
Optional[dict] = None) -> Any:
Review Comment:
```suggestion
def get_first(self, sql: Union[str, List[str]] = "", parameters:
Optional[Union[Iterable, Mapping]] = None) -> Any:
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]