Core Transformations⏱️ ~8 mins
2. Element-wise Metric Scaling
Enterprise Architecture Context
In production stream-processing architectures (Google Cloud Dataflow / Flink), pipeline stages must handle parallel transformations without data loss, managing schema mutations and aggregations across distributed worker workers.
Problem Statement
### Business Context
During signal processing in real-time acoustic telemetry, power measurements must be squared to compute the Root-Mean-Square (RMS) amplitude.
### Problem Statement
Write a function `square_numbers(input_pcoll)` that takes a `PCollection` of integers and squares each element (`x ** 2`), returning a PCollection with the transformed values.
Key Learning Objectives
- Understand distributed Apache Beam execution DAG stages and pipeline lifecycle.
- Apply idiomatic functional Python transforms using the pipe operator
|. - Ensure data consistency and idempotency across distributed stream workers.
Sample Data Fixtures
Sample Example 1
Input Stream:
[2, 3, 4]
Expected Output:
[4, 9, 16]
Sample Example 2
Input Stream:
[10, -5]
Expected Output:
[25, 100]
Topics:#Map#Math
solution.pyPython 3.11 (Apache Beam)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Input PCollection3 elements
| # | Element / Payload |
|---|---|
| 1 | 2 |
| 2 | 3 |
| 3 | 4 |
Expected Output PCollection3 elements
| # | Output Element |
|---|---|
| 1 | 4 |
| 2 | 9 |
| 3 | 16 |
Core Transformations⏱️ ~8 mins
2. Element-wise Metric Scaling
Enterprise Architecture Context
In production stream-processing architectures (Google Cloud Dataflow / Flink), pipeline stages must handle parallel transformations without data loss, managing schema mutations and aggregations across distributed worker workers.
Problem Statement
### Business Context
During signal processing in real-time acoustic telemetry, power measurements must be squared to compute the Root-Mean-Square (RMS) amplitude.
### Problem Statement
Write a function `square_numbers(input_pcoll)` that takes a `PCollection` of integers and squares each element (`x ** 2`), returning a PCollection with the transformed values.
Key Learning Objectives
- Understand distributed Apache Beam execution DAG stages and pipeline lifecycle.
- Apply idiomatic functional Python transforms using the pipe operator
|. - Ensure data consistency and idempotency across distributed stream workers.
Sample Data Fixtures
Sample Example 1
Input Stream:
[2, 3, 4]
Expected Output:
[4, 9, 16]
Sample Example 2
Input Stream:
[10, -5]
Expected Output:
[25, 100]
Topics:#Map#Math