nenkie76 opened a new issue, #35533:
URL: https://github.com/apache/airflow/issues/35533

   ### Apache Airflow version
   
   2.7.3
   
   ### What happened
   
   Airflow update from 2.7.2 to 2.7.3. (Astronomer 9.4.0 => 9.5.0) has changed 
the way SQL statements are parsed for Athena. Endlines are now ignored(?), 
which is causing issues with templated SQLs.
   
   For example. You have a templated `sql`, like below, with `--noqa` (due to 
linter configuration or smth else) :
   
   ```
   {% from 'vars.jinja' import date_from, date_to, athena_table_name, 
athena_table_s3_path with context %}  --noqa
   {% set dates_partition = some_function(date_from, date_to) %} --noqa
   
   alter table {{ athena_table_name }} add if not exists
   {% for partition_date in dates_partition %}
       partition (date = '{{ partition_date }}') location '{{ 
athena_table_s3_path }}{{ partition_date }}'
   {% endfor %}
   ```
   
   For version 2.7.2, you statement  in Athena would be:
   
   ```
   --noqa
   --noqa
   
   alter table transactions add if not exists 
       partition (date = '2023-09-23') location 's3://....'
   ```
   
   After 2.7.3 the same template is sent to Athena as:
   
   ```
   --noqa --noqa alter table transactions add if not exists partition (date = 
'2023-11-23') location 's3://...'
   ```
   
   So the statements are not having endlines and, in this case, ends up a 
completely commented statement.
   
   ### What you think should happen instead
   
   Statement executed on Athena should not change.
   
   ### How to reproduce
   
   Run templated `sql` statement using AthenaOperator with `--noqa`.
   
   ### Operating System
   
   Mac
   
   ### Versions of Apache Airflow Providers
   
   Astronomer 9.5.0
   
   ### Deployment
   
   Astronomer
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   I'm able to reproduce/revert this behaviour, switching between Astronomer 
9.4.0 (Airflow 2.7.2) and Astronomer 9.5.0 (Airflow 2.7.3) locally. 
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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-unsubscr...@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to