开始使用免费开始使用

ELT 中的 "T"

别忘了 ELT!此处 extract()load() 函数已为您定义好。现在只需完成 transform() 函数,然后运行整条流水线。加油!

本练习是课程的一部分

使用 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="____")
编辑并运行代码