uranusjr commented on code in PR #69695:
URL: https://github.com/apache/airflow/pull/69695#discussion_r3673386610
##########
providers/exasol/src/airflow/providers/exasol/hooks/exasol.py:
##########
@@ -184,11 +199,19 @@ def get_records(
"""
Execute the SQL and return a set of records.
- :param sql: the sql statement to be executed (str) or a list of
- sql statements to execute
- :param parameters: The parameters to render the SQL query with.
+ :param sql: the sql statement to be executed. Must be a single
``str``; pyexasol's ``execute()``
+ does not accept a list of statements. For executing multiple
statements in sequence, use
+ :meth:`run` with ``handler=exasol_fetch_all_handler`` instead.
+ :param parameters: The parameters to render the SQL query with. Must
be a ``dict``/``Mapping``;
+ pyexasol does not support positional (list/tuple) query parameters.
"""
- with closing(self.get_conn()) as conn, closing(conn.execute(sql,
parameters)) as cur:
+ if not isinstance(sql, str):
+ raise TypeError(
+ "ExasolHook.get_records() only supports a single SQL string,
not a list of statements. "
+ "Use ExasolHook.run() with a handler for executing multiple
statements."
+ )
Review Comment:
This is duplicated too many times. I would refactor it into a private
function called by each place. You can use `TypeGuard` to improve typing.
--
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]