I'm trying to generate a DataFrame with the following list of column names:
cols = [
'name',
'age',
'team',
'column1',
'column2',
'column3',
'column4',
'column5',
'column6',
]
rows = [Row(**{k: '1776-07-04'}) for k in cols]
df = spark.createDataFrame(rows)
If I run df.columns, the columns from the list above are returned as expected. But when I run df.show, I get the following error:
Caused by: java.lang.IllegalStateException: Input row doesn't have expected number of values required by the schema. 9 fields are required while 1 values are provided.
And so ultimatley I (somewhat) understand why i'm getting this error, but I was under the impression that 1776-07-04 would just be assigned to any/all values. What am I missing here?