I'm creating Row objects in Spark. I do not want my fields to be ordered alphabetically. However, if I do the following they are ordered alphabetically.
row = Row(foo=1, bar=2)
Then it creates an object like the following:
Row(bar=2, foo=1)
When I then create a dataframe on this object, the column order is going to be bar first, foo second, when I'd prefer to have it the other way around.
I know I can use "_1" and "_2" (for "foo" and "bar", respectively) and then assign a schema (with appropriate "foo" and "bar" names). But is there any way to prevent the Row object from ordering them?