開始使用免費開始

使用 zip 配對輸入

你的團隊有一條管線會把檔案上傳到特定的雲端儲存位置。同事使用 zip() 搭配 expand_kwargs(),把每個檔案與其雲端儲存目的地配對:

@task
def get_files():
    return ["users.csv", "orders.csv", "products.csv"]

@task
def get_destinations():
    return ["s3://bronze/users/", "s3://bronze/orders/", "s3://bronze/products/"]

@task
def upload(file_to_upload):
    # Simulate uploading a file to cloud storage
    print(f"Uploading {file_to_upload[0]} to {file_to_upload[1]}")

files = get_files()
destinations = get_destinations()
upload.expand(file_to_upload=files.zip(destinations))

Airflow 會建立多少個 upload 的實例?

本練習屬於課程

使用 Airflow 建置資料管線

檢視課程

動手互動練習

將理論付諸實踐,立即體驗我們的互動練習

開始練習