How do we append a constant environment tag to every record using the lit() function?
lit() converts a primitive Python string, integer, or float into a Spark Column literal.
Tagging pipeline source systems, environment identifiers, partition keys, and audit metadata.
from pyspark.sql.functions import lit
df = df.withColumn("environment", lit("PRODUCTION"))Practice typing production-grade PySpark code for Injecting Constant Literals with lit().