Skip to main content
PYSPARK โ€ข LESSON 58

Injecting Current Timestamp with current_timestamp()

How do we record the exact microsecond timestamp when records are processed by Spark?

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

How do we record the exact microsecond timestamp when records are processed by Spark?

๐Ÿ’ก WHAT IS IT?

current_timestamp() returns the current date and time as a TimestampType Column.

๐ŸŽฏ WHAT IS IT USED FOR?

Micro-batch stream auditing, SLA latency measurement, and event provenance tracking.

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

df = df.withColumn("processed_at", current_timestamp())

๐ŸŽฏ Mission Objectives

Practice typing production-grade PySpark code for Injecting Current Timestamp with current_timestamp().

  • โœ“ Import current_timestamp function
  • โœ“ Add precision timestamp Column
  • โœ“ Record pipeline processing time