Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to read raw data into the Bronze layer DataFrame.
Apache Spark
bronzeDF = spark.read.format([1]).load("/data/raw/events")
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'csv' format when data is JSON.
Using 'parquet' format before transformation.
✗ Incorrect
The Bronze layer usually ingests raw JSON data, so the format should be "json".
2fill in blank
mediumComplete the code to clean and transform Bronze data into Silver layer DataFrame.
Apache Spark
silverDF = bronzeDF.filter(bronzeDF.event_type.isNotNull()).selectExpr([1])Attempts:
3 left
💡 Hint
Common Mistakes
Selecting irrelevant columns for Silver layer.
Not filtering out null event_type values.
✗ Incorrect
Silver layer keeps cleaned and structured columns like event_id, user_id, and event_value.
3fill in blank
hardFix the error in the code that writes Silver data to the Silver table in Delta format.
Apache Spark
silverDF.write.format([1]).mode("overwrite").saveAsTable("silver_events")
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'json' or 'csv' format which do not support ACID.
Using 'parquet' without Delta features.
✗ Incorrect
The Silver layer is stored in Delta format for ACID transactions and versioning.
4fill in blank
hardFill both blanks to create a Gold layer table with aggregated data.
Apache Spark
goldDF = silverDF.groupBy([1]).agg({'event_value': [2])
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by event_type instead of user_id.
Using avg instead of sum for aggregation.
✗ Incorrect
Gold layer aggregates event_value by user_id using sum for total value per user.
5fill in blank
hardFill all three blanks to write the Gold DataFrame as a Delta table with partitioning.
Apache Spark
goldDF.write.format([1]).mode("overwrite").partitionBy([2]).saveAsTable([3])
Attempts:
3 left
💡 Hint
Common Mistakes
Not partitioning the Gold table.
Using wrong table name or format.
✗ Incorrect
Gold data is saved as Delta table partitioned by user_id for efficient queries.
