You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Yuri Au Yong <yu...@persistent.com> on 2015/10/08 11:52:11 UTC
resultset.getMetaData().getColumnName(idx) does not return alias name
Hi,
I find that resultset.getMetaData().getColumnName(idx) gives the table column name instead of assigned alias while resultset.getObject(<alias name>) returns columns value. Is this expected?
I ran test with reflective schema (see attached code ReflectiveSpec.txt), postgres with jdbc adaptor (see attached code PostgresSpec.txt) and also hqldb with jdbc adaptor. I also ran test with base connection for postgres and hsqldb where both returned alias name for resultset.getMetaData().getColumnName.
ReflectiveSpec: aliasTest
selectSomething - SQL: select V1 abc from test.t2
| V1(VARCHAR) | // resultset.getMetaData().getColumnName
|_|zero|_|
|_|half|_|
|_|one|_|
|_|two|_|
|_|three|_|
|_|four|_|
|_|null|_|
selectSomething - SQL: select V1 as abc from test.t2
| V1(VARCHAR) | // resultset.getMetaData().getColumnName
|_|zero|_|
|_|half|_|
|_|one|_|
|_|two|_|
|_|three|_|
|_|four|_|
|_|null|_|
selectWitName - SQL: select V1 as abc from test.t2 //using resultset.getObject("ABC")
|_|ABC: zero|_|
|_|ABC: half|_|
|_|ABC: one|_|
|_|ABC: two|_|
|_|ABC: three|_|
|_|ABC: four|_|
|_|ABC: null|_|
selectWitName - SQL: select V1 as abc from test.t2 //using resultset.getObject("V1")
java.sql.SQLException: column 'V1' not found
getColLabel - SQL: select V1 as abc from test.t2 //using resultset.getMetaData().getColumnLabel
| ABC(VARCHAR) |
Thanks & Regards,
Yuri Au Yong
Software Engineer - NPM | yuri.auyong@persistent.my | Desk: +60 3 7663 8372
Persistent Systems Ltd. | Partners in Innovation | www.persistentsys.com<http://www.persistentsys.com/>
[sign1]<https://tnpmsupport.persistentsys.com/training>
DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.