Alphan-Aksoyoglu opened a new issue, #35577:
URL: https://github.com/apache/airflow/issues/35577

   ### Apache Airflow version
   
   Other Airflow 2 version (please specify below)
   
   ### What happened
   
   Airflow Version: 2.5.3
   
   ### Summary
   
   using 
   ```python
   render_template_as_native_obj = True
   ```
   in DAG, causes operators with templated parameters to assign a different 
**type** then intended.
   
   ### Details
   
   ```python
   from airflow import DAG
   from airflow.providers.google.cloud.sensors.bigquery import 
BigQueryTablePartitionExistenceSensor
   
   my_dag = DAG(
                       dag_id="my_dag",
                       description="my_dag_description",
                       schedule=None,
                       max_active_runs=1,
                       render_template_as_native_obj=True,
                       catchup=False
                   )
   
   with my_dag:
   
       check_table_partition_exists = BigQueryTablePartitionExistenceSensor(    
            
           task_id="check_table_partition_exists",
           gcp_conn_id = "my_conn",
           project_id="my_project",
           dataset_id=f"my_dataset",
           table_id="my_table",
           mode = "reschedule",
           poke_interval = 10800,
           partition_id="20231023"
       )
   ```
   
   Following the **type** of partition_id through 
**BigQueryTablePartitionExistenceSensor** and **BigQueryHook** reveals that it 
is converted to **int** at execution time inside the 
**BigQueryTablePartitionExistenceSensor** instance.
   
   switching to
   
   ```python
   render_template_as_native_obj=False
   ```
   
   prevents this issue.
   
   ### What you think should happen instead
   
   This is a bit tricky,
   
   ```python
   render_template_as_native_obj = True
   ```
   
   infers **"20231013"** as an integer, is this intended? Probably so.
   
   - But if this is intended, then Operators that strictly expect a **str** 
object should typecast them during __init()__, should not they?
   
   [BigQueryTablePartitionExistenceSensor 
#L206](https://github.com/apache/airflow/blob/71f976d4f03b1aad13bd615740ee5667a4816d35/airflow/providers/google/cloud/sensors/bigquery.py#L206)
   
   ```python
   self.partition_id = str(partition_id)
   ```
   
   - Or maybe **render_template_as_native_obj** parameter could be supplemented 
with regex exclude conversion options, such as
   
   ```python
   render_template_as_native_obj = True
   exclude_native_obj_conversion = ["\d{8}","\d{4}-\d{2}-\d{2}"]
   ```
   
   Not sure how could this be achieved though, figuring out the templating goes 
over my head...
   
   ### How to reproduce
   
   Creating a sample DAG like in the **What Happened** section should be 
sufficient.
   
   logging **type(partition_id)** in the BigQueryTablePartitionExistenceSensor 
reveals that it arrives as an **integer**
   
   ### Operating System
   
   Debian GNU/Linux 11 (bullseye)
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-google==8.11.0
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] 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