How do we ingest raw customer CSV files with explicit schemas, filter corrupted IDs, and normalize text fields?
The initial stage of enterprise Medallion architectures: enforcing schemas, filtering null keys, and trimming strings.
Raw customer data ingestion, data sanitization, and audit timestamp generation.
from pyspark.sql.functions import col, current_timestamp, lower, trim
raw_customers = spark.read \
.schema(customer_schema) \
.option("header", "true") \
.csv("s3://raw/customers/*.csv")
clean_customers = raw_customers \
.filter(col("customer_id").isNotNull()) \
.withColumn("email", lower(trim(col("email")))) \
.withColumn("name", trim(col("name"))) \
.withColumn("cleaned_at", current_timestamp())Practice typing production-grade PySpark code for Raw Data Ingestion, Validation & Cleansing.