Passing Array to Spark Lit function
List comprehension inside Spark’s array a = [1,2,3,4,5,6,7,8,9,10] df = spark.createDataFrame([[‘a b c d e f g h i j ‘],], [‘col1’]) df = df.withColumn(“NewColumn”, F.array([F.lit(x) for x in a])) df.show(truncate=False) df.printSchema() # +——————–+——————————-+ # |col1 |NewColumn | # +——————–+——————————-+ # |a b c d e f g h i j |[1, 2, 3, 4, … Read more