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 19:23:48 UTC

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

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


##########
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:
   ```suggestion
           statements = list(
               filter(None, (s.rstrip(';') if s.endswith(';') else s for s in splits))
           )
   ```
   
   The `strip()` in the `else` part isn’t consistent. Alternatively, `strip()` should be done for both cases:
   
   ```python
   statements = (s.rstrip(';') if s.endswith(';') else s for s in splits)
   statements = (s.strip() for s in statements)
   return [s for s in statements if s]
   ```



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