ladderlore
请求新指南
  • 输入服务名称,例如 S3 或 IAM。

概念

Merging data from multiple sources

Join and union data from several sources: clean the keys first, pick the tool by size.

本课尚未翻译,暂以英文显示。

Orders (database)
Clicks (S3)
Align keys
Join
Parquet in S3
  1. 1Read the orders from the database.
  2. 2Read the click files from S3.
  3. 3Cast and clean the keys so they match, and union files by column name.
  4. 4Join, and write the result as Parquet in the curated zone.
Two sources, aligned keys, a join and a Parquet result.

分步说明

  1. 1Read the orders from the database.
  2. 2Read the click files from S3.
  3. 3Cast and clean the keys so they match, and union files by column name.
  4. 4Join, and write the result as Parquet in the curated zone.

Two sources, aligned keys, a join and a Parquet result.

  • Fits in memory

    Tool
    pandas
    Note
    Notebook or Processing job
  • SQL on S3 files

    Tool
    Athena CTAS
    Note
    Writes partitioned Parquet
  • Large data

    Tool
    Spark
    Note
    Glue or EMR. Broadcast or shuffle join
  • Only new data

    Tool
    Glue job bookmark
    Note
    Remembers what was read
Pick the merge tool by size and need.

1 / 2

  • Fits in memory

    Tool
    pandas
    Note
    Notebook or Processing job
  • SQL on S3 files

    Tool
    Athena CTAS
    Note
    Writes partitioned Parquet
  • Large data

    Tool
    Spark
    Note
    Glue or EMR. Broadcast or shuffle join

2 / 2

  • Only new data

    Tool
    Glue job bookmark
    Note
    Remembers what was read
Pick the merge tool by size and need.

是什么

Merging has two shapes. A join adds columns: orders get the customer record that matches their key. A union adds rows: files with the same layout stack into one table. Most failures come from the data, not the tool. Keys differ in type (a number in one source, text in another), in case, in spaces or in leading zeros. Schema drift adds, renames or retypes columns over time, so a union by position silently misaligns data. Clean and cast the keys first, and union by column name.

是什么

Pick the tool by size. Pandas joins small data in memory, in a notebook or a Processing job. Athena CTAS (CREATE TABLE AS SELECT) joins data in S3 with SQL and writes the result as partitioned Parquet. Spark in AWS Glue or Amazon EMR joins large data. A Spark broadcast join sends a small table to every worker, so the large table does not move: Spark does this by default for tables under 10 MB. A shuffle join moves both tables by key across the cluster and is slower, and a skewed key makes one worker slow.

是什么

For new data only, a Glue job bookmark remembers what a job already read, so the next run reads only new files or rows. In Glue, a DynamicFrame tolerates a column that has mixed types with a choice type that you resolve with a cast. Merge in the curated zone of the lake, and keep the raw sources untouched.

要记住

  • Join adds columns by key. Union adds rows with the same layout.
  • Align key type, case, spaces and leading zeros before joining.
  • Schema drift: union by column name, not by position.
  • Small: pandas. SQL on S3: Athena CTAS. Large: Spark in Glue or EMR.
  • Broadcast join for one small table (default under 10 MB). Shuffle join for two large ones.

要记住

  • Glue job bookmarks load only new data on each run.

考试中

  • “Join a small lookup table with billions of rows in Spark” points to a broadcast join.
  • “Each nightly run must read only new files” points to Glue job bookmarks.
  • “Join S3 tables with SQL and save the result as Parquet” points to Athena CTAS.