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

   ### Apache Airflow version
   
   3.1.4
   
   ### If "Other Airflow 2/3 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   The bug in the following issue was never solved:
   
   https://github.com/apache/airflow/issues/10160
   
   Jinja2 templating does not work and one can not change the 
template_searchpath such that the (for example) sql file is recognized.
   
   
   There is just a workaround using the open_maybe_zipped utils function and 
using it to open the file manually before giving the path to the Operator, like 
this:
   
   ```
   from airflow.utils.file import open_maybe_zipped
   
   
open_maybe_zipped("/home/airflow/gcs/dags/test.zip/test_sql/test.sql").read()`
   ```
   
   
   ### What you think should happen instead?
   
   _No response_
   
   ### How to reproduce
   
   
   In `/home/airflow/gcs/dags/test.zip/test_sql/test.sql`:
   ```
   SELECT column_a FROM test
   ```
   
   In `/home/airflow/gcs/dags/test.zip/test.py`:
   
   ```
   from airflow import DAG
   from airflow.providers.google.cloud.operators.bigquery import 
BigQueryInsertJobOperator
   from airflow.utils.file import open_maybe_zipped
   
   # Define DAG
   with DAG(
       dag_id="test_import_path_dag",
       schedule_interval=None,
       template_searchpath="/home/airflow/gcs/dags/test",
       default_args = {"retries": 0}
   ) as dag:
   
       test = BigQueryInsertJobOperator(
           task_id="test_task",
           configuration={
               "query": {
                   "query": "test_sql/test.sql" ,   # PATH HERE IS NOT FOUND 
WHEN DAGS ARE ZIPPED
                   "useLegacySql": False,
                   "destinationTable": {
                       "projectId": "test",
                       "datasetId": "test",
                       "tableId": "test",
                   },
               }
           },
       )
   
       test
   ```
   
   ### Operating System
   
   Linux
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Google Cloud Composer
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to