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!

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();
}
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!

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 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch