I would like to pass a list of strings, containing the name of files in google storage to XCom. Later to be picked up by a GoogleCloudStorageToBigQueryOperator task. The source_objects field is templated, so that Jinja templating can be used. Unfortunately, Jinja can only return a string, and thus I cannot pass the list in XCom.
How can I use a XCom list in GoogleCloudStorageToBigQueryOperator?
Reference to a similar question, solved by using provide_context: Pass a list of strings as parameter of a dependant task in Airflow
The closest solution I've found, which works, is to create a wrapper class and sending the id of the task who posted the xcom like so:
@apply_defaults
def __init__(self, source_objects_task_id,
....
def execute(self, context):
source_objects = context['ti']
.xcom_pull(task_ids=self.source_objects_task_id)
operator = GoogleCloudStorageToBigQueryOperator(
source_objects=source_objects,
dag=self.dag,
....
)
operator.execute(context)