Re: How to get columnName as `COUNT(*)` , not `EXPR$0`

2019-09-28 Thread XING JIN
You can check the below doc of SqlValidatorUtil#getAlias for explanation:

  /**
   * Derives an alias for a node, and invents a mangled identifier if it
   * cannot.
   *
   * Examples:
   *
   * 
   * Alias: "1 + 2 as foo" yields "foo"
   * Identifier: "foo.bar.baz" yields "baz"
   * Anything else yields "expr$ordinal"
   * 
   *
   * @return An alias, if one can be derived; or a synthetic alias
   * "expr$ordinal" if ordinal  0; otherwise null
   */
  public static String getAlias(SqlNode node, int ordinal)

But from my experience, you'd better not rely on above logic heavily. If
you really care about the output name, just give it an alias explicitly.

Juan Pan  于2019年9月29日周日 下午1:27写道:

> That means Calcite can only return real columnName or columnLabel from
> simple column or alias. And any aggregate function, or calculate expression
> without alias, parsing expression, i.e, `EXPR$0` will be returned?
>
>
>  Juan Pan
>
>
> panj...@apache.org
> Juan Pan(Trista), Apache ShardingSphere
>
>
> On 09/29/2019 13:16,XING JIN wrote:
> If no column name given explicitly, e.g. by alias or simple identifier,
> Calcite will derive one but not from the aggregate function.
>
> Juan Pan  于2019年9月29日周日 下午1:12写道:
>
> Thank for your reply. It is a indirect way to get columnName.
>
>
> Calcite can not return the real columnName from SQL, is it right?
>
>
> Juan Pan
>
>
> panj...@apache.org
> Juan Pan(Trista), Apache ShardingSphere
>
>
> On 09/29/2019 12:21,XING JIN wrote:
> You can try to give an alias for the selected column.
>
> Juan Pan  于2019年9月29日周日 上午11:39写道:
>
>
>
> Hi everyone,
>
>
> I executed SQL `select count(*) from tb1` through Calcite and
> resultSet.getMetaData().getColumnName(i) in my project. But the result is
> `EXPR$0` not `COUNT(*)`.
>
>
> Is there any way to get real columnName?
>
>
> Thanks for your attention.
>
>
> Regard,
> Trista
>
>
>
>
> Juan Pan
>
>
> panj...@apache.org
> Juan Pan(Trista), Apache ShardingSphere
>
>
>
>


Re: How to get columnName as `COUNT(*)` , not `EXPR$0`

2019-09-28 Thread Juan Pan
That means Calcite can only return real columnName or columnLabel from simple 
column or alias. And any aggregate function, or calculate expression without 
alias, parsing expression, i.e, `EXPR$0` will be returned?


 Juan Pan


panj...@apache.org
Juan Pan(Trista), Apache ShardingSphere


On 09/29/2019 13:16,XING JIN wrote:
If no column name given explicitly, e.g. by alias or simple identifier,
Calcite will derive one but not from the aggregate function.

Juan Pan  于2019年9月29日周日 下午1:12写道:

Thank for your reply. It is a indirect way to get columnName.


Calcite can not return the real columnName from SQL, is it right?


Juan Pan


panj...@apache.org
Juan Pan(Trista), Apache ShardingSphere


On 09/29/2019 12:21,XING JIN wrote:
You can try to give an alias for the selected column.

Juan Pan  于2019年9月29日周日 上午11:39写道:



Hi everyone,


I executed SQL `select count(*) from tb1` through Calcite and
resultSet.getMetaData().getColumnName(i) in my project. But the result is
`EXPR$0` not `COUNT(*)`.


Is there any way to get real columnName?


Thanks for your attention.


Regard,
Trista




Juan Pan


panj...@apache.org
Juan Pan(Trista), Apache ShardingSphere





Re: How to get columnName as `COUNT(*)` , not `EXPR$0`

2019-09-28 Thread XING JIN
If no column name given explicitly, e.g. by alias or simple identifier,
Calcite will derive one but not from the aggregate function.

Juan Pan  于2019年9月29日周日 下午1:12写道:

> Thank for your reply. It is a indirect way to get columnName.
>
>
> Calcite can not return the real columnName from SQL, is it right?
>
>
>  Juan Pan
>
>
> panj...@apache.org
> Juan Pan(Trista), Apache ShardingSphere
>
>
> On 09/29/2019 12:21,XING JIN wrote:
> You can try to give an alias for the selected column.
>
> Juan Pan  于2019年9月29日周日 上午11:39写道:
>
>
>
> Hi everyone,
>
>
> I executed SQL `select count(*) from tb1` through Calcite and
> resultSet.getMetaData().getColumnName(i) in my project. But the result is
> `EXPR$0` not `COUNT(*)`.
>
>
> Is there any way to get real columnName?
>
>
> Thanks for your attention.
>
>
> Regard,
> Trista
>
>
>
>
> Juan Pan
>
>
> panj...@apache.org
> Juan Pan(Trista), Apache ShardingSphere
>
>
>


Re: How to get columnName as `COUNT(*)` , not `EXPR$0`

2019-09-28 Thread Juan Pan
Thank for your reply. It is a indirect way to get columnName. 


Calcite can not return the real columnName from SQL, is it right?


 Juan Pan


panj...@apache.org
Juan Pan(Trista), Apache ShardingSphere


On 09/29/2019 12:21,XING JIN wrote:
You can try to give an alias for the selected column.

Juan Pan  于2019年9月29日周日 上午11:39写道:



Hi everyone,


I executed SQL `select count(*) from tb1` through Calcite and
resultSet.getMetaData().getColumnName(i) in my project. But the result is
`EXPR$0` not `COUNT(*)`.


Is there any way to get real columnName?


Thanks for your attention.


Regard,
Trista




Juan Pan


panj...@apache.org
Juan Pan(Trista), Apache ShardingSphere




Re: How to get columnName as `COUNT(*)` , not `EXPR$0`

2019-09-28 Thread XING JIN
You can try to give an alias for the selected column.

Juan Pan  于2019年9月29日周日 上午11:39写道:

>
>
> Hi everyone,
>
>
> I executed SQL `select count(*) from tb1` through Calcite and
> resultSet.getMetaData().getColumnName(i) in my project. But the result is
> `EXPR$0` not `COUNT(*)`.
>
>
> Is there any way to get real columnName?
>
>
> Thanks for your attention.
>
>
> Regard,
> Trista
>
>
>
>
>  Juan Pan
>
>
> panj...@apache.org
> Juan Pan(Trista), Apache ShardingSphere
>
>


How to get columnName as `COUNT(*)` , not `EXPR$0`

2019-09-28 Thread Juan Pan


Hi everyone,


I executed SQL `select count(*) from tb1` through Calcite and 
resultSet.getMetaData().getColumnName(i) in my project. But the result is 
`EXPR$0` not `COUNT(*)`. 


Is there any way to get real columnName?


Thanks for your attention.


Regard,
Trista




 Juan Pan


panj...@apache.org
Juan Pan(Trista), Apache ShardingSphere