開始使用免費開始

ELT 裡的「T」

別忘了 ELT!這裡已經幫你定義好 extract()load() 函式。現在只差完成 transform() 函式,然後執行整條 pipeline。加油!

本練習屬於課程

使用 Python 的 ETL 與 ELT

檢視課程

練習說明

  • 更新 transform() 函式,對 data_warehouse 物件呼叫 .execute() 方法。
  • 使用剛更新的 transform() 函式,將 raw_sales_data 來源資料表轉換後,寫入 total_sales 目標資料表。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Complete building the transform() function
def transform(source_table, target_table):
  data_warehouse.____(f"""
  CREATE TABLE {target_table} AS
      SELECT
          CONCAT("Product ID: ", product_id),
          quantity * price
      FROM {source_table};
  """)

extracted_data = extract(file_name="raw_sales_data.csv")
load(data_frame=extracted_data, table_name="raw_sales_data")

# Populate total_sales by transforming raw_sales_data
____(source_table="____", target_table="____")
編輯並執行程式碼