Skip to main content
PYSPARK โ€ข LESSON 57

Injecting Current Date with current_date()

How do we stamp the current execution date onto all ingested records in an ETL pipeline?

Intermediateโฑ 2 Minutesโญ 300 XP
๐Ÿค” THE QUESTION

How do we stamp the current execution date onto all ingested records in an ETL pipeline?

๐Ÿ’ก WHAT IS IT?

current_date() returns the current calendar date as a DateType Column evaluated at query execution time.

๐ŸŽฏ WHAT IS IT USED FOR?

Batch ETL partitioning, daily audit stamping, and tracking lakehouse ingestion dates.

๐Ÿ’ป EXAMPLE
from pyspark.sql.functions import current_date

df = df.withColumn("ingestion_date", current_date())

๐ŸŽฏ Mission Objectives

Practice typing production-grade PySpark code for Injecting Current Date with current_date().

  • โœ“ Import current_date function
  • โœ“ Inject current date Column
  • โœ“ Stamp batch ETL ingestion date