You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Liya Fan (Jira)" <ji...@apache.org> on 2022/03/04 11:56:00 UTC

[jira] [Updated] (CALCITE-2552) JDBC adapter generates Non-Dialect Specific Order By Field Identifier

     [ https://issues.apache.org/jira/browse/CALCITE-2552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Liya Fan updated CALCITE-2552:
------------------------------
    Fix Version/s:     (was: 1.30.0)

> JDBC adapter generates Non-Dialect Specific Order By Field Identifier
> ---------------------------------------------------------------------
>
>                 Key: CALCITE-2552
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2552
>             Project: Calcite
>          Issue Type: Bug
>          Components: jdbc-adapter
>            Reporter: KrishnaKant Agrawal
>            Assignee: yanjing.wang
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> 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!),
> {code:java}
> Select first_name as n1 from emp order by first_name;{code}
> Expected SQL,
> {code:java}
> Select first_name as n1 from emp order by n1;{code}
> The Code Excerpt Responsible for this particular use case:- (SqlImplementor.java:952)
> {code:java}
> public SqlNode field(int ordinal) {
>   final SqlNode selectItem = selectList.get(ordinal);
>   switch (selectItem.getKind()) {
>   case AS:
>     return ((SqlCall) selectItem).operand(0);
>   }
>   return selectItem;
> }{code}
>  
>  I create the TableScan, Projection(with the alias) & Sort in the mentioned order.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)