Move the generation of output column names earlier, to right after name
resolution and before query transformations such as flattening. This prevents
the names from getting mangled by query transformations, and obviates hacks
in the query flattener that attempt to work around the name mangling.
The resulting code is smaller and faster and gives more consistent output.
This is an alternative fix to ticket [
de3403bf5ae5f72ed].
FossilOrigin-Name:
09834279aeca3bda63de684a369ed64f2cbf587b5f5df1454c0a3c009a1337ad