How to get column name from dynamic data type which is defined in tMysqlInput?

Highlighted
Four Stars

How to get column name from dynamic data type which is defined in tMysqlInput?

Dear all,

 

I want to get all the column name which is defined on tMysqlInput component and the flow is contained in the picture below.

 

abc.PNG

 

- Inside the tMysqlInput, I defined the Query which related to context variables, so it will change sometimes I run it. So I defined the Schema which is "dynamic" type.

 

- My target is getting all the column name with it's data in Mysql.

 

Who can help me for this case please!!!

Thank you guys!

Highlighted
Eight Stars

Re: How to get column name from dynamic data type which is defined in tMysqlInput?

Try this in your java row

Dynamic dyn = row1.dynamic_column_name;
Set<String> columns = dyn.getAllColumnNames();

If you want to loop through them all you can do something like

for(int i = 0; i < dyn.getColumnCount(); i++){
	DynamicMetadata meta = dyn.getColumnMetadata(i);
        String col_name = meta.getName();
}
Highlighted
Four Stars

Re: How to get column name from dynamic data type which is defined in tMysqlInput?

Thank you @evansdar for your help. It worked perfectly!

Highlighted
Four Stars

Re: How to get column name from dynamic data type which is defined in tMysqlInput?

Also, my currently purpose is getting data from mysql (about rows size which I defined before) and then put it into dataset. The final flow is:

 

gola.PNG

 

Could you please help me how can I transform it into dataset from tMysqlInput (which used my custom query)?

 

Thank you and hope you have a happy day!

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog