Get Attribute Values from Custom Class in Talend

Highlighted
Four Stars

Get Attribute Values from Custom Class in Talend

Hello Everyone!

I have new to Talend, and Everyone was going fine until I ran into basic issue. I have a function that returns more than one value, so I created a class to hold these values and my function returns a type of that class. Now, in a TMap how can call this function once, and use the same object on different columns?


Thanks!

Eight Stars

Re: Get Attribute Values from Custom Class in Talend

Hi there,

 

I'd suggest calling your function in a tJavaRow, and then setting the output row columns based on the properties of the returned class. You could add any necessary new flow fields in the output schema as required.

 

Depending how often you're likely to use this, you may even find it easier to simply drop the function code into your tJavaFlow component, where it can directly set the output flow columns, meaning you'd not need to create the return Class/object in the first place.

 

 

Regards,

 

 

Chris

Four Stars

Re: Get Attribute Values from Custom Class in Talend

Thanks for your reply. Do you have an example that I can use to fully understand. Thanks again!
Eight Stars

Re: Get Attribute Values from Custom Class in Talend

Here's a very basic example to illustrate this:

 

tJavaRow.png

 

In this case, the tFixedFlowInput generates rows which have two columns, and I've added two new columns to the output schema of the tJavaRow which are then populated in the code.

 

tJavaRowSchema.png

 

When setting this up in your own job, you'll likely want to click "Generate Code" once you have the input and output connected to the tJavaFlow, added/removed fields from the output schema, and before you begin adding your own code etc., as this will generate the basic code to pass data from all of the input to the output fields.

 

Regards,

 

 

Chris

 

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

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog