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/08/14 16:55:17 UTC

[GitHub] [airflow] kazanzhy commented on a diff in pull request #25713: Fix SQL split string to include `;-less` statements

kazanzhy commented on code in PR #25713:
URL: https://github.com/apache/airflow/pull/25713#discussion_r945316074


##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -244,7 +244,9 @@ def split_sql_string(sql: str) -> List[str]:
         :return: list of individual expressions
         """
         splits = sqlparse.split(sqlparse.format(sql, strip_comments=True))
-        statements = [s.rstrip(';') for s in splits if s.endswith(';')]
+        statements: List[str] = list(
+            filter(None, [s.rstrip(';') if s.endswith(';') else s.strip() for s in splits])
+        )

Review Comment:
   I wonder what you think about the FP style:
   ```
   statements: List[str] = list(filter(None, map(lambda x: x.strip().rstrip(';'), splits)))
   ```



-- 
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