You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/05/30 01:01:07 UTC
[GitHub] [airflow] uranusjr commented on a diff in pull request #23971: Unify DbApiHook.run() method with the methods which override it
uranusjr commented on code in PR #23971:
URL: https://github.com/apache/airflow/pull/23971#discussion_r884352816
##########
airflow/hooks/dbapi.py:
##########
@@ -160,7 +161,25 @@ def get_first(self, sql, parameters=None):
cur.execute(sql)
return cur.fetchone()
- def run(self, sql, autocommit=False, parameters=None, handler=None):
+ @staticmethod
+ def maybe_split_sql_string(sql: str) -> List[str]:
+ """
+ Splits strings consisting of multiple SQL expressions into an
+ TODO: do we need something more sophisticated?
+
+ :param sql: SQL string potentially consisting of multiple expressions
+ :return: list of individual expressions
+ """
+ splits = [s.strip() for s in re.split(";\\s*\r?\n", sql) if s.strip() != ""]
+ return splits
Review Comment:
I think we are using sqlparse for some of the hooks; we should use it here as well. It is a pretty small dependency and more reliable than whatever we come up with.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org