In PySpark, I don't want to hardcode the schema definition, I want to derive the schema from below variable.
mySchema=[("id","IntegerType()", True),
("name","StringType()", True),
("InsertDate","TimestampType()", True)
]
result = mySchema.map(lambda l: StructField(l[0],l[1],l[2]))
How do I achieve this logic to generate the structTypeSchema from mySchema?
Expected output:
structTypeSchema = StructType(fields=[
StructField("id", IntegerType(), True),
StructField("name", StringType(), True),
StructField("InsertDate",TimestampType(), True)])