For example:
df = spark.read.json("path")
print(df.schema)
prints:
StructType(List(StructField(timestamp,StringType,true)))
rather than:
StructType([StructField("timestamp",StringType(),True)])
This is an issue for me if i want to come up with a schema by initially inferring the schema from a file in order to then print the schema and hardcode it in my code.
Is there a way to print the schema of a dataframe and have it in python syntax so that i can set a hardcoded schema to a variable in my code and use it?