How to get alias applied when gessing shema from a query?

One Star

How to get alias applied when gessing shema from a query?

Hi,
I am new to this forum and quite new to Talend also. I am using it as an ETL to populate my datawarehouse and perform some audit stuff.
In order to retrieve data from a MySQL source, I wrote a query using some alias to get proper naming but Talend does not take them into account when gessing the schema.
Let take a basic example:
If I use the following query
"SELECT
s1.code as source1_code,
s2.code as source2_code
FROM
Source1 s1 INNER JOIN Source2 s2 ON s1.source2_id=s2.id"
Talend gess code and code1 instead of source1_code and source2_code.
Could anyone help?
Thanks
Seventeen Stars

Re: How to get alias applied when gessing shema from a query?

This is not a problem caused by Talend. This is caused by the database driver and its usage of database metadata.
I have a very similar problem with DB2.
A way to forth the driver to use the alias is to fake a funktion:
in case of a number field (s1.code+0) as source1_code
in case of a character field (s1.code||'') as source1_code
This way you will probably get the alias name instead of the original column name.
One Star

Re: How to get alias applied when gessing shema from a query?

Ok thanks
I confirm the way you fake function works good to get the alias name.
But I think I will prefer renaming the column names by myself before storing them into generic schemas. Maybe it is a more proper way.