The next step is convert your schema to upper case.
scol = [col.upper() for col in df.schema.fieldNames()] df = df.toDF(*scol)
That solves your issue. Also, compare your table schema and df schema before write.