I am migrating some DAG's from "Cloud Composer-1 Airflow-1" to Cloud "Composer-2 Airflow-2".
I have created a custom module called BigQuerySqlSensor acting like a SqlSensor for BigQuery.
I have done this by creating another custom module called MySqlSensor because Airflow has removed some of the supported attributes for BaseHook and recommended to use DbApiHook instead.
I have basically used the same source code of SqlSensor (can be found here) and replaced BaseHook module with DbApiHook.
Then I used the MySqlSensor to create custom BigQuerySqlSensor like below:
class BigQuerySqlSensor(MySqlSensor):
def _get_hook(self):
hook = super()._get_hook()
hook.use_legacy_sql = False
return hook
The task where I am calling the BigQuerySqlSensor is:
task = BigQuerySqlSensor(
task_id='my_task',
conn_id='bigquery_default',
timeout= <Some Numbers>
poke_interval= <Some Numbers>
mode='reschedule',
sql='my_sql.sql'
)
However, I am getting an error such as:
records = hook.get_records(self.sql, self.parameters)
AttributeError: 'GoogleBaseHook' object has no attribute 'get_records'
I am not sure where GoogleBaseHook is being picked up. I am guessing it is something to do with the connection in Airflow.
In my previous Cloud Composer instance, I am running the same code with same configurations and connections. I am out of ideas at this point. Any ideas would be appreciated!