def exec_replace_or_upsert(task: schema.Task, runner: QueryRunner, **kwargs): airflow_context = kwargs["airflow_context"] relation = create_relation_from_task(task=task) sql = airflow_context["templates_dict"]["sql"] dag_run_conf = (airflow_context["dag_run"].conf if airflow_context["dag_run"].conf else {}) full_refresh = dag_run_conf.get("full_refresh", False) if type(full_refresh) != bool: raise RuntimeError( "Dag config `full_refresh` must be set to either `true` or `false` (as a boolean value)." ) logging.info(f"### IS FULL REFRESH ENABLED: {full_refresh}") runner.replace_or_upsert( query=sql, relation=relation, options={ "partition_key": task.partitioning.field if task.partitioning else None, "partition_data_type": task.partitioning.data_type if task.partitioning else None, "full_refresh": full_refresh, }, )
def exec_replace_or_upsert(task: schema.Task, runner: QueryRunner, **kwargs): airflow_context = kwargs['airflow_context'] relation = create_relation_from_task(task=task) sql = airflow_context['templates_dict']['sql'] dag_run_conf = airflow_context['dag_run'].conf if airflow_context['dag_run'].conf else {} full_refresh = dag_run_conf.get('full_refresh', False) if type(full_refresh) != bool: raise RuntimeError('Dag config `full_refresh` must be set to either `true` or `false` (as a boolean value).') logging.info(f'### IS FULL REFRESH ENABLED: {full_refresh}') runner.replace_or_upsert( query=sql, relation=relation, options={ 'partition_key': task.partitioning.field if task.partitioning else None, 'partition_data_type': task.partitioning.data_type if task.partitioning else None, 'full_refresh': full_refresh } )