snc-lin opened a new issue, #47053:
URL: https://github.com/apache/airflow/issues/47053

   ### Apache Airflow Provider(s)
   
   google
   
   ### Versions of Apache Airflow Providers
   
   12.0.0
   
   ### Apache Airflow version
   
   2.10.5
   
   ### Operating System
   
   Ubuntu 22.04.5 LTS
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### What happened
   
   If the value of the GoogleBaseHook field is False, it always returns the 
default value.
   Specifically, even if use_legacy_sql in BigQueryHook is set to False, it 
still returns the default value of True.
   
   ### What you think should happen instead
   
   If use_legacy_sql in BigQueryHook is set to False, the use_legacy_sql 
parameter should also be False.
   
   ### How to reproduce
   
   Create a BigQuery connection with use_legacy_sql set to False (e.g. 
`bigquery_default`).
   Create a BigQuery connection with use_legacy_sql set to False (for example, 
bigquery_default). And, run the following code.
   
   ```
   from airflow.decorators import dag, task
   from airflow.providers.google.cloud.hooks.bigquery import BigQueryHook
   
   @dag()
   def bigquery_dag():
       @task()
       def debug():
           hook = BigQueryHook.get_hook("bigquery_default")
           print(hook.use_legacy_sql)
   
       debug()
   
   bigquery_dag()
   ```
   
   ### Anything else
   
   I think I need to fix the 
code(https://github.com/apache/airflow/blob/providers-google/12.0.0/providers/src/airflow/providers/google/common/hooks/base_google.py#L412)
 as follows.
   
   before: 
   `return hasattr(self, "extras") and get_field(self.extras, f) or default`
   
   after: 
   ```
   if hasattr(self, "extras") and get_field(self.extras, f) is not None:
       return get_field(self.extras, f)
   else:
       default
   ```
   
   ### 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