[ 
https://issues.apache.org/jira/browse/CALCITE-3261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16911617#comment-16911617
 ] 

Julian Hyde commented on CALCITE-3261:
--------------------------------------

I agree, it might be nice.

We must not change the column aliases automatically assigned for sub-queries 
and other relational algebra nodes. The "EXPR$n" logic is called widely, and 
appears in a lot of test output.

At the top level of a statement you could derive the labels for JDBC based on 
the SqlParserPos of the items in the SELECT clause.

What does MySQL do if the expression has an alias? if the expression has an 
alias that contains a space? if the expression is of the form 
"tableAlias.column"? if the SQL text is too long? if it contains spaces? if it 
contains back-ticks or double-quotes (which are difficult to escape)? if the 
SQL text is not unique? if the expression contains two or more consecutive 
spaces? if the expression is "null"? It's worth writing down all of these 
examples, and more, as use cases.

> Make JDBC output column labels more human readable
> --------------------------------------------------
>
>                 Key: CALCITE-3261
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3261
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core, jdbc-adapter
>            Reporter: Xiaoguang zhang
>            Assignee: Xiaoguang Zhang
>            Priority: Major
>
> After implementing the missing `print(ResultSet)` method from the examples in 
> Calcite [tutorial|[https://calcite.apache.org/docs/index.html]], I found that 
> the output field names are incorrect:
> {code:java}
> [deptno, EXPR$1]
> [1, 1]
> [2, 2]
> {code}
> The field name `EXPR$1` can be improved to be more human readable like MySQL 
> client:
> {code:java}
> +--------+--------------+
> | deptno | min(e.empid) |
> +--------+--------------+
> |      1 |            1 |
> |      2 |            2 |
> +--------+--------------+
> {code}
>  
> PS: the sql statement generating the above outputs:
> {code:sql}
> select d.deptno, min(e.empid) from hr.emps as e join hr.depts as d on 
> e.deptno = d.deptno group by d.deptno having count(*) > 1
> {code}



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to