The Order By Keys when resolved during RelToSql Conversion is hardcoded to fallback to Original Expression instead of an alias(if present)
This should be based on the Dialect set in RelToSqlConverter.
If the Order By Key is a Projection which was Aliased, the Output query contains the original column name instead of the Alias, which is not allowed in HIVE as valid Order By keys are to be selected from Select List Identifiers only.
Generated SQL(Failing in hive!),
The Code Excerpt Responsible for this particular use case:- (SqlImplementor.java:952)
I create the TableScan, Projection(with the alias) & Sort in the mentioned order.