Creates a Column of literal value
代码示例:
from pyspark.sql import SparkSession,functions as F
def main():
spark=SparkSession.builder.appName("ade_als_related").getOrCreate()
df=spark.createDataFrame([('1992-7-8',),('1997-9-10',)],['d'])
#
df1=df.select(F.col("d"),F.lit(5).alias("heigth")).withColumn("spark_user",F.lit(True))
df1.show()
if __name__ == '__main__':
main()
运行结果: