It sounds like a bug. Can you please log a JIRA case. We should consult the target dialect and generate sql according to the rules for what is allowed in ORDER BY.
In calcite, and probably also in hive, “ORDER BY emp.first_name” would be valid. But probably “ORDER BY <ordinal>” is the best solution on dialects that support it (and most do). Julian > On Sep 3, 2018, at 09:41, Krishnakant Agrawal <[email protected]> wrote: > > Hi All, > > I am trying to convert a Simple RelNode to SQL Text with Hive as Dialect > using RelToSqlConverter. > > Problem is 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 projections only. > > For Instance, > Select first_name as n1 from emp order by first_name; (Failing in hive!) > > Expected SQL, > Select first_name as n1 from emp order by n1; > > I create the TableScan, Projection(with the alias) & Sort in the mentioned > order. > > Any leads would be greatly appreciated. > > Thanks & Regards, > Krishnakant
